Sha256: 8c8249642bafd4a1c3d3e6bfdc4cffd57fda7a860227dd91b13173b50393936f

Contents?: true

Size: 566 Bytes

Versions: 21

Compression:

Stored size: 566 Bytes

Contents

class Dorsale::Alexandrie::AttachmentsSorter < Agilibox::Sorter
  def sort
    case column
    when :created_at, :updated_at
      {column => direction}
    when :name
      Arel.sql %(LOWER(#{model.table_name}.#{column}) #{direction})
    when :attachment_type_name
      @collection = @collection.joins(:attachment_type)
      table = Dorsale::Alexandrie::AttachmentType.table_name
      Arel.sql %(LOWER(#{table}.name) #{direction})
    else
      {created_at: :desc, id: :desc}
    end
  end

  private

  def model
    Dorsale::Alexandrie::Attachment
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
dorsale-4.0.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.20.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.19.1 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.19.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.18.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.17.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.16.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.15.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.11 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.10 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.9 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.8 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.7 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.6 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.5 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.4 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.3 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.2 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.1 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.14.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb