Module: WrapIt::DerivedAttributes::ClassMethods
- Defined in:
- lib/wrap_it/derived_attributes.rb
Overview
Class methods to include
Instance Method Summary collapse
Instance Method Details
#collect_derived(name, initial = [], method = :concat) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wrap_it/derived_attributes.rb', line 26 def collect_derived(name, initial = [], method = :concat) result = initial # if instance_variable_defined?(name) # result = result.send(method, instance_variable_get(name)) # end ancestors.each do |ancestor| break if ancestor == Object next unless ancestor.instance_variable_defined?(name) result = result.send(method, ancestor.instance_variable_get(name)) end result end |
#get_derived(name) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/wrap_it/derived_attributes.rb', line 16 def get_derived(name) return instance_variable_get(name) if instance_variable_defined?(name) ancestors.each do |ancestor| break if ancestor == Object next unless ancestor.instance_variable_defined?(name) return ancestor.instance_variable_get(name) end nil end |