Module: LogicalModel::ResponsesConfiguration::ClassMethods
- Defined in:
- lib/logical_model/responses_configuration.rb
Instance Method Summary collapse
- #collection_key ⇒ Object
-
#configure_index_response(hash_response) ⇒ Object
By default paginate and all will expect a response in the format: { collection: [.…], total: X } Where collection contains an array of hashes that initialize the Object and total contains the total number of elements in result (used for pagination).
- #total_key ⇒ Object
Instance Method Details
#collection_key ⇒ Object
26 27 28 |
# File 'lib/logical_model/responses_configuration.rb', line 26 def collection_key @collection_key ||= 'collection' end |
#configure_index_response(hash_response) ⇒ Object
By default paginate and all will expect a response in the format: { collection: [.…], total: X } Where collection contains an array of hashes that initialize the Object and total contains the total number of elements in result (used for pagination)
configure_index_response allows to change this defaults. If collection is nil then array is expected at root and total will be ignored. If total is nil it will be ignored
21 22 23 24 |
# File 'lib/logical_model/responses_configuration.rb', line 21 def configure_index_response(hash_response) @collection_key = hash_response[:collection] @total_key = hash_response[:total] end |
#total_key ⇒ Object
30 31 32 |
# File 'lib/logical_model/responses_configuration.rb', line 30 def total_key @total_key ||= 'total' end |