Module: Lazy::Attribute::ClassMethods
- Defined in:
- lib/lazy/attribute/lazy_attribute.rb
Instance Method Summary collapse
-
#lazy_attribute(attribute, options = {}) ⇒ none
Including the lazy_attribute gem to the model.
Instance Method Details
#lazy_attribute(attribute, options = {}) ⇒ none
Including the lazy_attribute gem to the model
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lazy/attribute/lazy_attribute.rb', line 17 def lazy_attribute(attribute, = {}) = {raise_error: false, key: '[]', create_if_not_found: false} .reverse_merge!() singleton_class.instance_eval do define_method([:key]) do |identifier| send(dynamic_find_method(), {attribute.to_sym => identifier}) end end end |