Class: MongoPopulator::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_populator/record.rb

Overview

This is what is passed to the block when calling populate.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject

Returns the value of attribute attributes.



4
5
6
# File 'lib/mongo_populator/record.rb', line 4

def attributes
  @attributes
end