Module: Omnis::MongoQuery::ClassMethods

Includes:
Query::ClassMethods
Defined in:
lib/omnis/mongo_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Query::ClassMethods

#param, #params

Instance Attribute Details

#items_per_pageObject (readonly)

Returns the value of attribute items_per_page.



17
18
19
# File 'lib/omnis/mongo_query.rb', line 17

def items_per_page
  @items_per_page
end

#page_param_nameObject (readonly)

Returns the value of attribute page_param_name.



17
18
19
# File 'lib/omnis/mongo_query.rb', line 17

def page_param_name
  @page_param_name
end

#sort_default_fieldObject (readonly)

Returns the value of attribute sort_default_field.



17
18
19
# File 'lib/omnis/mongo_query.rb', line 17

def sort_default_field
  @sort_default_field
end

#sort_default_orderObject (readonly)

Returns the value of attribute sort_default_order.



17
18
19
# File 'lib/omnis/mongo_query.rb', line 17

def sort_default_order
  @sort_default_order
end

#sort_param_nameObject (readonly)

Returns the value of attribute sort_param_name.



17
18
19
# File 'lib/omnis/mongo_query.rb', line 17

def sort_param_name
  @sort_param_name
end

Instance Method Details

#field_listObject



18
19
20
# File 'lib/omnis/mongo_query.rb', line 18

def field_list
  @fields ||= []
end

#fields(list) ⇒ Object



21
22
23
# File 'lib/omnis/mongo_query.rb', line 21

def fields(list)
  field_list.concat(list)
end

#page(page_param_name, opts = {}) ⇒ Object



25
26
27
28
# File 'lib/omnis/mongo_query.rb', line 25

def page(page_param_name, opts={})
  @page_param_name = page_param_name
  @items_per_page  = opts[:items_per_page] || 10
end

#sort(sort_param_name, opts = {}) ⇒ Object



30
31
32
33
34
# File 'lib/omnis/mongo_query.rb', line 30

def sort(sort_param_name, opts={})
  @sort_param_name  = sort_param_name
  @sort_default_field = opts[:default][0]
  @sort_default_order = (opts[:default][1] || :asc).to_sym
end