Class: MongoModel::InstrumentedCursor

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/support/instrumented_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cursor) ⇒ InstrumentedCursor

Returns a new instance of InstrumentedCursor.



10
11
12
# File 'lib/mongomodel/support/instrumented_collection.rb', line 10

def initialize(cursor)
  @cursor = cursor
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



27
28
29
# File 'lib/mongomodel/support/instrumented_collection.rb', line 27

def method_missing(method, *args, &block)
  cursor.send(method, *args, &block)
end

Instance Attribute Details

#cursorObject (readonly)

Returns the value of attribute cursor.



8
9
10
# File 'lib/mongomodel/support/instrumented_collection.rb', line 8

def cursor
  @cursor
end

Instance Method Details

#countObject



20
21
22
23
24
# File 'lib/mongomodel/support/instrumented_collection.rb', line 20

def count
  instrument("count(#{cursor.selector.inspect})") do
    cursor.count
  end
end

#to_aObject



14
15
16
17
18
# File 'lib/mongomodel/support/instrumented_collection.rb', line 14

def to_a
  instrument(query_description) do
    cursor.to_a
  end
end