Class: Gizmo::FindAll

Inherits:
BaseOperation show all
Defined in:
lib/gizmo/find_all.rb

Instance Attribute Summary

Attributes inherited from BaseOperation

#context

Instance Method Summary collapse

Methods inherited from BaseOperation

#create_response, #default_status, #initialize, #set_response_headers

Constructor Details

This class inherits a constructor from Gizmo::BaseOperation

Instance Method Details

#call(criteria) ⇒ Gizmo::Response

Find all items using the provided criteria.

Parameters:

  • criteria (Mongoid::Criteria)

    the criteria to use for finding all items

Returns:



9
10
11
12
13
14
15
# File 'lib/gizmo/find_all.rb', line 9

def call(criteria)
  response = create_response
  all_items = criteria.all
  response.header 'X-Total-Results', all_items.count
  response.data = all_items
  response
end