module Croods::Resource::Sorting

Public Instance Methods

order_attribute() click to toggle source
# File lib/croods/resource/sorting.rb, line 12
def order_attribute
  @order_attribute ||= Croods::Attribute.new(
    'order', :string, null: true
  )
end
order_by_attribute() click to toggle source
# File lib/croods/resource/sorting.rb, line 6
def order_by_attribute
  @order_by_attribute ||= Croods::Attribute.new(
    'order_by', :string, null: true
  )
end
order_params() click to toggle source
# File lib/croods/resource/sorting.rb, line 18
def order_params
  @order_params ||= [order_by_attribute, order_attribute]
end
sort_by(sort = nil) click to toggle source
# File lib/croods/resource/sorting.rb, line 27
def sort_by(sort = nil)
  return @sort_by ||= :created_at unless sort

  @sort_by ||= sort
end
sort_by_method?() click to toggle source
# File lib/croods/resource/sorting.rb, line 22
def sort_by_method?
  sort_by.is_a?(Symbol) && !sort_by.to_s.in?(attribute_names) &&
    model.respond_to?(sort_by)
end