Method: Aspire::Object::ResourcePropertyMixin#method_missing
- Defined in:
- lib/aspire/object/resource.rb
#method_missing(method_name, *args, &block) ⇒ Object
Handles citation_<property>() accessor calls by proxying to the parent resource if no instance value is set. The <property> accessor for this instance is called first, and if this returns nil and there is a parent resource (is_part_of), the property accessor of the parent is called. This continues up through the ancestor resources until a value is found. Positional and keyword arguments are passed to the property accessor
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aspire/object/resource.rb', line 22 def method_missing(method_name, *args, &block) property_name = get_property_name_from_method(method_name) super if property_name.nil? # Try the resource's property first value = public_send(property_name, *args, &block) return value unless value.nil? # Delegate to the parent resource's property if it exists # Call the parent's citation_<property> rather than <property> to # delegate up the ancestor chain. if is_part_of value = is_part_of.public_send(method_name, *args, &block) return value unless value.nil? end # Otherwise return nil nil end |