Sha256: 9df9dd4d255954f97c8a7ab8943c9a0d31da731a2545a377a529594b25c2f74b

Contents?: true

Size: 601 Bytes

Versions: 64

Compression:

Stored size: 601 Bytes

Contents

class Agilibox::Sorter
  include Agilibox::SortingHelper

  attr_reader :collection, :sort_param, :column, :direction

  def initialize(collection, sort_param = nil)
    @collection         = collection
    @sort_param         = sort_param
    @column, @direction = sortable_column_order(sort_param.to_s)
  end

  def sort
    raise NotImplementedError
  end

  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

  def self.call(*args)
    new(*args).call
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
agilibox-2.0.0 app/sorters/agilibox/sorter.rb
agilibox-1.11.0 app/sorters/agilibox/sorter.rb
agilibox-1.10.5 app/sorters/agilibox/sorter.rb
agilibox-1.10.2 app/sorters/agilibox/sorter.rb
agilibox-1.10.1 app/sorters/agilibox/sorter.rb
agilibox-1.10.0 app/sorters/agilibox/sorter.rb
agilibox-1.9.20 app/sorters/agilibox/sorter.rb
agilibox-1.9.19 app/sorters/agilibox/sorter.rb
agilibox-1.9.18 app/sorters/agilibox/sorter.rb
agilibox-1.9.17 app/sorters/agilibox/sorter.rb
agilibox-1.9.16 app/sorters/agilibox/sorter.rb
agilibox-1.9.15 app/sorters/agilibox/sorter.rb
agilibox-1.9.14 app/sorters/agilibox/sorter.rb
agilibox-1.9.13 app/sorters/agilibox/sorter.rb
agilibox-1.9.12 app/sorters/agilibox/sorter.rb
agilibox-1.9.11 app/sorters/agilibox/sorter.rb
agilibox-1.9.10 app/sorters/agilibox/sorter.rb
agilibox-1.9.9 app/sorters/agilibox/sorter.rb
agilibox-1.9.8 app/sorters/agilibox/sorter.rb
agilibox-1.9.7 app/sorters/agilibox/sorter.rb