Class: Easymongo::Result
- Inherits:
-
Object
- Object
- Easymongo::Result
- Defined in:
- lib/easymongo/result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#options ⇒ Object
Returns the value of attribute options.
-
#result ⇒ Object
Returns the value of attribute result.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
-
#bson_id ⇒ Object
Get the id as BSON::ObjectId.
-
#date ⇒ Object
Creation date.
-
#id ⇒ Object
Get the id if available.
-
#initialize(result, data, values = nil, options = nil) ⇒ Result
constructor
Init takes a Mongo::Operation::Result.
-
#method_missing(name, *args, &block) ⇒ Object
For the mongo operation result.
Constructor Details
#initialize(result, data, values = nil, options = nil) ⇒ Result
Init takes a Mongo::Operation::Result
7 8 9 10 11 12 |
# File 'lib/easymongo/result.rb', line 7 def initialize(result, data, values = nil, = nil) self.result = result self.data = data self.values = values self. = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
For the mongo operation result
30 31 32 33 |
# File 'lib/easymongo/result.rb', line 30 def method_missing(name, *args, &block) return result.send(name, *args) if result.respond_to?(name) super end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/easymongo/result.rb', line 4 def data @data end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/easymongo/result.rb', line 4 def end |
#result ⇒ Object
Returns the value of attribute result.
4 5 6 |
# File 'lib/easymongo/result.rb', line 4 def result @result end |
#values ⇒ Object
Returns the value of attribute values.
4 5 6 |
# File 'lib/easymongo/result.rb', line 4 def values @values end |
Instance Method Details
#bson_id ⇒ Object
Get the id as BSON::ObjectId
15 16 17 |
# File 'lib/easymongo/result.rb', line 15 def bson_id result.upserted_id || data['_id'] end |
#date ⇒ Object
Creation date
25 26 27 |
# File 'lib/easymongo/result.rb', line 25 def date bson_id ? bson_id.generation_time : nil end |
#id ⇒ Object
Get the id if available
20 21 22 |
# File 'lib/easymongo/result.rb', line 20 def id bson_id ? bson_id.to_s : nil end |