Sha256: ffec251877dd11f885a24ffec8fe8ed04456c90c087d52047caa83b19dafff1f

Contents?: true

Size: 548 Bytes

Versions: 8

Compression:

Stored size: 548 Bytes

Contents

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

  private

  def model
    Dorsale::Alexandrie::Attachment
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dorsale-3.12.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.11.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.10.3 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.10.2 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.10.1 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.10.0 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.9.8 app/sorters/dorsale/alexandrie/attachments_sorter.rb
dorsale-3.9.7 app/sorters/dorsale/alexandrie/attachments_sorter.rb