Module: Godmin::Resources::ResourceService::Ordering

Extended by:
ActiveSupport::Concern
Included in:
Godmin::Resources::ResourceService
Defined in:
lib/godmin/resources/resource_service/ordering.rb

Instance Method Summary collapse

Instance Method Details

#apply_order(order_param, resources) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/godmin/resources/resource_service/ordering.rb', line 7

def apply_order(order_param, resources)
  if order_param.present? && order_column_method?(order_column(order_param))
    send("order_by_#{order_column(order_param)}", resources, order_direction(order_param))
  elsif order_param.present? && order_column_column?(order_column(order_param))
    resources.order("#{resource_class.table_name}.#{order_column(order_param)} #{order_direction(order_param)}")
  else
    resources
  end
end

#orderable_column?(column) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/godmin/resources/resource_service/ordering.rb', line 17

def orderable_column?(column)
  order_column_method?(column) || order_column_column?(column)
end