Module: SupplejackApi::Sortable::Query::ClassMethods

Defined in:
lib/supplejack_api/admin/sortable.rb

Instance Method Summary collapse

Instance Method Details

#sortable(options = {}) ⇒ Object


25
26
27
28
29
30
31
32
33
34
# File 'lib/supplejack_api/admin/sortable.rb', line 25

def sortable(options = {})
  options = options.try(:symbolize_keys) || {}
  options[:page] ||= 1
  options[:per_page] ||= 25

  scope = unscoped
  scope = scope.sort_order(options[:order]) if options[:order]
  scope = scope.page(options[:page]).per(options[:per_page])
  scope
end