Method: Order#orderable
- Defined in:
- lib/order.rb
#orderable(*attribute_names) ⇒ Object #orderable(attribute_map) ⇒ Object #orderable(order_name, &block) ⇒ Object
Generates order_by_* scopes used for ordering resulting records.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/order.rb', line 27 def orderable(*attributes, &block) if block_given? raise ArgumentError.new('Cannot provide mapped naming for custom ordering strategy') if attributes.first.is_a? Hash order_scope attributes.first, &block elsif attributes.first.is_a? Hash attributes.first.each{ |name, attribute| order_scope name, attribute } else attributes.each{ |attribute| order_scope attribute } end end |