Sha256: 7ab10c2c37942863bc0df84ff60bde44c287500316122ad3ba88fc0692db5108
Contents?: true
Size: 1.11 KB
Versions: 21
Compression:
Stored size: 1.11 KB
Contents
class LogicalModel module ResponsesConfiguration def self.included(base) base.send(:extend, ClassMethods) end module ClassMethods # 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. # @example # configure_index_response {collection: 'items', total: 'count'} # This will expect response to have format: {items: [...], count: X} # # If collection is nil then array is expected at root and total will be ignored. # If total is nil it will be ignored def configure_index_response(hash_response) @collection_key = hash_response[:collection] @total_key = hash_response[:total] end def collection_key @collection_key ||= 'collection' end def total_key @total_key ||= 'total' end end end end
Version data entries
21 entries across 21 versions & 1 rubygems