Class: MiniMongo::Base
- Inherits:
-
Object
- Object
- MiniMongo::Base
- Includes:
- Mapper
- Defined in:
- lib/mini_mongo/base.rb
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Base
constructor
A new instance of Base.
Methods included from Mapper
Constructor Details
#initialize(attrs = {}) ⇒ Base
Returns a new instance of Base.
4 5 6 7 8 9 10 11 12 |
# File 'lib/mini_mongo/base.rb', line 4 def initialize(attrs = {}) attrs["id"] = attrs["_id"].to_s attrs.delete("_id") attrs.each do |key, value| instance_variable_set("@#{key}", value) self.instance_eval("def #{key};@#{key};end") self.instance_eval("def #{key}=(val);@#{key}=val;end") end end |