Class: Easymongo::Result
- Inherits:
-
Object
- Object
- Easymongo::Result
- Defined in:
- lib/easymongo/result.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
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) ⇒ Result
constructor
Init takes a Mongo::Operation::Result.
-
#method_missing(name, *args, &block) ⇒ Object
For the mongo operation result.
Constructor Details
#initialize(result) ⇒ Result
Init takes a Mongo::Operation::Result
7 8 9 |
# File 'lib/easymongo/result.rb', line 7 def initialize(result) @result = result 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
27 28 29 30 |
# File 'lib/easymongo/result.rb', line 27 def method_missing(name, *args, &block) return result.send(name, *args) if result.respond_to?(name) super end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
4 5 6 |
# File 'lib/easymongo/result.rb', line 4 def result @result end |
Instance Method Details
#bson_id ⇒ Object
Get the id as BSON::ObjectId
12 13 14 |
# File 'lib/easymongo/result.rb', line 12 def bson_id result.upserted_id rescue nil end |
#date ⇒ Object
Creation date
22 23 24 |
# File 'lib/easymongo/result.rb', line 22 def date bson_id ? bson_id.generation_time : nil end |
#id ⇒ Object
Get the id if available
17 18 19 |
# File 'lib/easymongo/result.rb', line 17 def id bson_id ? bson_id.to_s : nil end |