class Hoodoo::Services::Interface::ToList
A class containing a series of accessors that describe allowed parameters in a “list” call for a service implementation. The middleware uses this validate incoming query strings for lists and reject requests that ask for unsupported things. When instantiated the class sets itself up with defaults that match those described by the your platform’s API. When passed to a Hoodoo::Services::Interface::ToListDSL
instance, the DSL methods, if called, update the values stored herein.
Attributes
Default sort key.
Array of prohibited framework filter keys as Strings; empty for none defined.
Array of prohibited framework search keys as Strings; empty for none defined.
Array of supported filter keys as Strings; empty for none defined.
Limit value; an integer that limits page size in lists.
Array of supported search keys as Strings; empty for none defined.
Sort hash. Keys are supported sort fields, values are arrays of supported sort directions. The first array entry is the default sort order for the sort field.
Public Class Methods
Create an instance with default settings.
# File lib/hoodoo/services/services/interface.rb, line 77 def initialize # Remember, these are defaults for the "to_list" object of an # interface only. For interface-wide top level defaults, use the # embedded calls to the DSL in Interface::interface. @limit = 50 @sort = { 'created_at' => Set.new( [ 'desc', 'asc' ] ) } @default_sort_key = 'created_at' @search = [] @do_not_search = [] @filter = [] @do_not_filter = [] end
Public Instance Methods
Default sort direction.
# File lib/hoodoo/services/services/interface.rb, line 53 def default_sort_direction @sort[ default_sort_key() ].first end