Class: Hippo::API::ControllerBase
- Inherits:
-
Object
- Object
- Hippo::API::ControllerBase
- Includes:
- FormattedReply
- Defined in:
- lib/hippo/api/controller_base.rb
Overview
The Controller handles querying models using either pre-defined scopes or hash based queries; and also including optional associations with the reply
It assigns the following meaning the these parameters.
* f: (fields) Include the following fields (usually methods) with the reply
* w: (with) Uses the defined scope to query and/or add extra data to the model
* q: (query) Query the model using fields and values
it is an array of clauses, which can be either forms
{ field: value }, or { field: { op: 'like', value: 'value%' } }
* i: (include) Include associations along with the model in the reply
* o: (order) Order by, { field => "ASC|DESC" }
* l: (limit) Limit the returned rows to the count
* s: (start) Start the query at the given offset (for paging)
* df: (data format) Should data be returned as 'object' (default) or 'array'
The parameters are deliberately shortened so they can be used in query parameters without blowing the URL up to an unacceptable length
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(model, authentication, params, data = {}) ⇒ ControllerBase
constructor
A new instance of ControllerBase.
Methods included from FormattedReply
#json_status_str, #record_active_record_errors, #records_for_reply, #std_api_reply
Constructor Details
#initialize(model, authentication, params, data = {}) ⇒ ControllerBase
Returns a new instance of ControllerBase.
29 30 31 32 33 34 |
# File 'lib/hippo/api/controller_base.rb', line 29 def initialize(model, authentication, params, data={}) @model = model @params = params @data = data @authentication = authentication end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
26 27 28 |
# File 'lib/hippo/api/controller_base.rb', line 26 def data @data end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
26 27 28 |
# File 'lib/hippo/api/controller_base.rb', line 26 def model @model end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
26 27 28 |
# File 'lib/hippo/api/controller_base.rb', line 26 def params @params end |