Sha256: 7bcc0df612985a1256b0d5df1e4ce00bf3324d288c22d6cdd23892469a085618

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

module MagicGrid
  module Order
    class Unordered
      def self.css_class
        'sort-none'
      end
      def self.icon_class
        'ui-icon-carat-2-n-s'
      end
      def self.to_sql
        'ASC'
      end
      def self.to_param
        0
      end
      def self.sorted?
        false
      end
      def self.reverse
        Descending
      end
    end
    class Unsortable < Unordered; end
    class Ascending < Unordered
      def self.css_class
        'sort-asc'
      end
      def self.icon_class
        'ui-icon-triangle-1-n'
      end
      def self.sorted?
        true
      end
      def self.reverse
        Descending
      end
    end
    class Descending < Unordered
      def self.css_class
        'sort-desc'
      end
      def self.icon_class
        'ui-icon-triangle-1-s'
      end
      def self.to_sql
        'DESC'
      end
      def self.to_param
        1
      end
      def self.sorted?
        true
      end
      def self.reverse
        Ascending
      end
    end
    def self.from_param(something)
      case something
      when 1, "1", :desc, :DESC, "desc", "DESC", Descending
        Descending
      #when 0, "0", :asc, :ASC, "asc", "ASC", Ascending
      #  Ascending
      else
        Ascending
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
magic_grid-0.12.6 lib/magic_grid/order.rb
magic_grid-0.12.5 lib/magic_grid/order.rb