Class: MundaneSearch::Filters::Order

Inherits:
Typical show all
Defined in:
lib/mundane-search/filters/order.rb

Direct Known Subclasses

ActiveRecord

Defined Under Namespace

Classes: ActiveRecord

Instance Attribute Summary

Attributes inherited from Base

#collection, #options, #params

Instance Method Summary collapse

Methods inherited from Typical

#apply?, #key, key_type, #key_type, key_types, #match_value, #optional?, #target

Methods inherited from Base

#apply?, #call, #filtered_params, #initialize

Constructor Details

This class inherits a constructor from MundaneSearch::Filters::Base

Instance Method Details

#filtered_collectionObject



14
15
16
17
# File 'lib/mundane-search/filters/order.rb', line 14

def filtered_collection
  sorted = collection.sort_by(&:"#{match_value}")
  backwards? ? sorted.reverse : sorted
end