Class: MongoModel::MongoOptions

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

Constant Summary collapse

ValidKeys =
[ :conditions, :select, :offset, :limit, :order ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, options = {}) ⇒ MongoOptions

Returns a new instance of MongoOptions.



9
10
11
12
13
14
15
16
17
18
# File 'lib/mongomodel/support/mongo_options.rb', line 9

def initialize(model, options={})
  options.assert_valid_keys(ValidKeys)
  
  @model = model
  
  @selector = extract_conditions(options)
  @options  = extract_options(options)
  
  add_type_to_selector
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/mongomodel/support/mongo_options.rb', line 7

def options
  @options
end

#selectorObject (readonly)

Returns the value of attribute selector.



7
8
9
# File 'lib/mongomodel/support/mongo_options.rb', line 7

def selector
  @selector
end

Instance Method Details

#to_aObject



20
21
22
# File 'lib/mongomodel/support/mongo_options.rb', line 20

def to_a
  [selector, options]
end