Class: Mongoid::FakeCriteria

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/fake_criteria.rb

Instance Method Summary collapse

Constructor Details

#initialize(documents) ⇒ FakeCriteria

Returns a new instance of FakeCriteria.


4
5
6
# File 'lib/mongoid/fake_criteria.rb', line 4

def initialize(documents)
  @documents = documents
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object


24
25
26
# File 'lib/mongoid/fake_criteria.rb', line 24

def method_missing(*args, &block)
  @documents.send(*args, &block)
end

Instance Method Details

#as_json(options = {}) ⇒ Object


19
20
21
# File 'lib/mongoid/fake_criteria.rb', line 19

def as_json(options={})
  @documents.as_json(options)
end

#limit(quantity) ⇒ Object


9
10
11
# File 'lib/mongoid/fake_criteria.rb', line 9

def limit(quantity)
  Mongoid::FakeCriteria.new(@documents[0..quantity-1])
end

#rawObject


14
15
16
# File 'lib/mongoid/fake_criteria.rb', line 14

def raw
  @documents
end