Class: MongoPopulator::Record
- Inherits:
-
Object
- Object
- MongoPopulator::Record
- Defined in:
- lib/mongo_populator/record.rb
Overview
This is what is passed to the block when calling populate.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(collection) ⇒ Record
constructor
Creates a new instance of Record.
Constructor Details
#initialize(collection) ⇒ Record
Creates a new instance of Record.
7 8 9 |
# File 'lib/mongo_populator/record.rb', line 7 def initialize(collection) @attributes = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object (private)
20 21 22 23 24 25 26 27 28 |
# File 'lib/mongo_populator/record.rb', line 20 def method_missing(sym, *args, &block) name = sym.to_s if name.include?('=') rtn = MongoPopulator.interpret_value(args.first) @attributes[name.sub('=', '').to_sym] = rtn else @attributes[sym] end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/mongo_populator/record.rb', line 4 def attributes @attributes end |