Module: Modelize::Core
- Defined in:
- lib/modelize/core.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
Instance Method Summary collapse
-
#method_missing(name, *args, &block) ⇒ Object
Read and write to the BSON::Document.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Read and write to the BSON::Document
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/modelize/core.rb', line 7 def method_missing(name, *args, &block) # Extract name and write mode name =~ /([^=]+)(=)?/ # Call methods before instance variables return args[0] ? @doc.send($1, args[0]) : @doc.send($1) if @doc.respond_to?($1) # Write or read the BSON::Document, nil if nothing found return args[0] ? @doc[$1] = args[0] : @doc[$1] end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
4 5 6 |
# File 'lib/modelize/core.rb', line 4 def doc @doc end |