Method: MongoThing::Document::InstanceMethods#method_missing
- Defined in:
- lib/mongo_thing/document.rb
#method_missing(mid, *args) ⇒ Object
OpenStruct like behavior
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/mongo_thing/document.rb', line 91 def method_missing(mid, *args) # :nodoc: mname = mid.id2name chomped = mname.chomp('=') len = args.length if self.class.properties.include?(chomped.to_sym) if mname == chomped && len > 0 || len > 1 raise NoMethodError, "undefined method `#{mname}' for #{self}", caller(1) end new_attribute(mname.chomp('=')) @attributes.send(mid, *args) else raise NoMethodError, "undefined method `#{mname}' for #{self}", caller(1) end end |