Module: EncryptAttributes::Macros
- Defined in:
- lib/encrypt_attributes/macros.rb
Instance Method Summary collapse
Instance Method Details
#encrypt_attrs(*attr_names) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/encrypt_attributes/macros.rb', line 3 def encrypt_attrs(*attr_names) mod = Module.new mod.module_eval do attr_names.each do |attr_name| # getter define_method(attr_name) do read_encrypted_attribute(attr_name) end # setter define_method("#{attr_name}=") do |value| write_encrypted_attribute(attr_name, value) end end end include mod end |