Module: HalApi::Controller::Sorting

Extended by:
ActiveSupport::Concern
Included in:
HalApi::Controller
Defined in:
lib/hal_api/controller/sorting.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#sorted(arel) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/hal_api/controller/sorting.rb', line 25

def sorted(arel)
  apply_sorts = !sorts.blank? ? sorts : default_sort
  if apply_sorts.blank?
    super
  else
    arel.order(*apply_sorts)
  end
end

#sortsObject



21
22
23
# File 'lib/hal_api/controller/sorting.rb', line 21

def sorts
  @sorts ||= parse_sorts_param
end