Module: Thyng::CryptedAspect
- Defined in:
- lib/thyng/crypted_aspect.rb
Instance Method Summary collapse
Instance Method Details
#crypted_accessor(aspect) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/thyng/crypted_aspect.rb', line 5 def crypted_accessor(aspect) crypted_aspect = "crypted_#{aspect}" aspect_accessor crypted_aspect define_method "#{aspect}=", ->(value) { send "#{crypted_aspect}=", BCrypt::Password.create(value) } define_method aspect, -> () { BCrypt::Password.new send(crypted_aspect) } define_method "check_#{aspect}?", -> (test_value) { send(aspect) == test_value } end |