Class: Mingo
- Inherits:
-
Hash
- Object
- Hash
- Mingo
- Extended by:
- ActiveModel::Translation, Connection, Finders, Many
- Includes:
- ActiveModel::Conversion, Callbacks, Changes, Persistence, Properties
- Defined in:
- lib/mingo.rb,
lib/mingo/cursor.rb,
lib/mingo/changes.rb,
lib/mingo/finders.rb,
lib/mingo/callbacks.rb,
lib/mingo/connection.rb,
lib/mingo/many_proxy.rb,
lib/mingo/properties.rb,
lib/mingo/timestamps.rb,
lib/mingo/persistence.rb
Defined Under Namespace
Modules: Callbacks, Changes, Connection, Finders, Many, Persistence, Properties, Timestamps Classes: Cursor, ManyProxy
Instance Attribute Summary
Attributes included from Connection
Attributes included from Changes
Instance Method Summary collapse
- #==(other) ⇒ Object
- #id ⇒ Object
-
#initialize(obj = nil) ⇒ Mingo
constructor
A new instance of Mingo.
Methods included from Connection
collection_name, connect, connected?
Methods included from Finders
Methods included from Many
Methods included from Changes
Methods included from Callbacks
Methods included from Properties
#[], #[]=, #inspect, #stringify_keys, #stringify_keys!, #to_hash
Constructor Details
#initialize(obj = nil) ⇒ Mingo
Returns a new instance of Mingo.
35 36 37 38 39 40 41 42 43 |
# File 'lib/mingo.rb', line 35 def initialize(obj = nil) super() if obj # a doc loaded straight from the db? if obj['_id'].is_a? BSON::ObjectId then merge!(obj) else obj.each { |prop, value| self.send("#{prop}=", value) } end end end |
Instance Method Details
#==(other) ⇒ Object
54 55 56 |
# File 'lib/mingo.rb', line 54 def ==(other) other.is_a?(self.class) and other.id == self.id end |
#id ⇒ Object
50 51 52 |
# File 'lib/mingo.rb', line 50 def id self['_id'] end |