neilmiddleton / attr_secure

MIT License
11 stars 1 forks source link

Custom Secret #7

Closed dmathieu closed 11 years ago

dmathieu commented 11 years ago

This adds custom secret :

With a static string (no variables can be used here)

attr_secure :my_attribute, :secret => "..."

With a lambda (object is the current instance of the atribute's object).

attr_secure :my_attribute, :secret => lambda {|object| object.user.secret }
dmathieu commented 11 years ago

@neilmiddleton: I don't really see the point for string secrets. A lambda one is interesting as it allows having differents secrets depending of the instance. However, the only point I see for strings would be to use an other environment variable.

neilmiddleton commented 11 years ago

Fair point with the lambda vs strings - I'm happy with that.

dmathieu commented 11 years ago

@neilmiddleton: I've just split the secret retrieval into it's own object. I've also (re)refactored the tests to not make them interdependent. If that's fine with you, this can be merged.

neilmiddleton commented 11 years ago

Awesome. :thumbsup: