Class: BMC::Sorter
- Inherits:
-
Object
- Object
- BMC::Sorter
- Includes:
- SortingHelper
- Defined in:
- app/sorters/bmc/sorter.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#sort_param ⇒ Object
readonly
Returns the value of attribute sort_param.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(collection, sort_param, options = {}) ⇒ Sorter
constructor
A new instance of Sorter.
- #sort ⇒ Object
Methods included from SortingHelper
#sortable_column, #sortable_column_order
Constructor Details
#initialize(collection, sort_param, options = {}) ⇒ Sorter
Returns a new instance of Sorter.
10 11 12 13 14 15 |
# File 'app/sorters/bmc/sorter.rb', line 10 def initialize(collection, sort_param, = {}) @collection = collection @sort_param = sort_param @options = @column, @direction = sortable_column_order(sort_param.to_s) end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
4 5 6 |
# File 'app/sorters/bmc/sorter.rb', line 4 def collection @collection end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
4 5 6 |
# File 'app/sorters/bmc/sorter.rb', line 4 def column @column end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
4 5 6 |
# File 'app/sorters/bmc/sorter.rb', line 4 def direction @direction end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'app/sorters/bmc/sorter.rb', line 4 def @options end |
#sort_param ⇒ Object (readonly)
Returns the value of attribute sort_param.
4 5 6 |
# File 'app/sorters/bmc/sorter.rb', line 4 def sort_param @sort_param end |
Class Method Details
.call ⇒ Object
6 7 8 |
# File 'app/sorters/bmc/sorter.rb', line 6 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 |
# File 'app/sorters/bmc/sorter.rb', line 21 def call # Don't replace by `collection.reorder(sort)` # #sort can change #collection and must be called before #collection order = sort collection.reorder(order) end |
#sort ⇒ Object
17 18 19 |
# File 'app/sorters/bmc/sorter.rb', line 17 def sort raise NotImplementedError end |