Module: Croods::Resource::Sorting
- Defined in:
- lib/croods/resource/sorting.rb
Instance Method Summary collapse
- #order_attribute ⇒ Object
- #order_by_attribute ⇒ Object
- #order_params ⇒ Object
- #sort_by(attribute = nil) ⇒ Object
Instance Method Details
#order_attribute ⇒ Object
12 13 14 15 16 |
# File 'lib/croods/resource/sorting.rb', line 12 def order_attribute @order_attribute ||= Croods::Attribute.new( 'order', :string, null: true ) end |
#order_by_attribute ⇒ Object
6 7 8 9 10 |
# 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 ⇒ Object
18 19 20 |
# File 'lib/croods/resource/sorting.rb', line 18 def order_params @order_params ||= [order_by_attribute, order_attribute] end |
#sort_by(attribute = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/croods/resource/sorting.rb', line 22 def sort_by(attribute = nil) return @sort_by ||= :created_at unless attribute @sort_by ||= attribute end |