module Origami::FieldAccessor
Provides an easier syntax for field access. The object must have the defined the methods [] and []=.
Once included, object.Field will automatically resolve to object. References are automatically followed.
Public Instance Methods
method_missing(field, *args)
click to toggle source
# File lib/origami/object.rb, line 97 def method_missing(field, *args) raise NoMethodError, "No method `#{field}' for #{self.class}" unless field =~ /^[[:upper:]]/ if field[-1] == '=' self[field[0..-2].to_sym] = args.first else object = self[field] object.is_a?(Reference) ? object.solve : object end end
respond_to_missing?(field, *)
click to toggle source
Calls superclass method
# File lib/origami/object.rb, line 108 def respond_to_missing?(field, *) not (field =~ /^[[:upper:]]/).nil? or super end