Sha256: eea446ced17ee45b217b6361698ab62a3d1afaeb719c5de50ff676c42c62164e

Contents?: true

Size: 704 Bytes

Versions: 16

Compression:

Stored size: 704 Bytes

Contents

module FortyFacets
  # Stores the parameters of a order criteria for a search.
  class OrderDefinition
    attr(:title, :clause, :default)

    def initialize title, clause
      @title = title
      @clause = clause
      @default = false

      if clause.is_a? Hash
        if clause[:order] && clause[:default]
          @clause = clause[:order]
          @default = clause[:default]
        end
      end
    end

    def build(search, order_param)
      Order.new(search, self, order_param == title.to_s)
    end

    # Returns the value that is used in the request parameter to indicate that
    # the search result is ordered by this criteria.
    def request_value
      title
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
forty_facets-0.2.1 lib/forty_facets/order_definition.rb
forty_facets-0.2 lib/forty_facets/order_definition.rb
forty_facets-0.1.9.1 lib/forty_facets/order_definition.rb
forty_facets-0.1.9.0 lib/forty_facets/order_definition.rb
forty_facets-0.1.8.9 lib/forty_facets/order_definition.rb
forty_facets-0.1.8 lib/forty_facets/order_definition.rb
forty_facets-0.1.7 lib/forty_facets/order_definition.rb
forty_facets-0.1.6 lib/forty_facets/order_definition.rb
forty_facets-0.1.5 lib/forty_facets/order_definition.rb
forty_facets-0.1.4 lib/forty_facets/order_definition.rb
forty_facets-0.1.3 lib/forty_facets/order_definition.rb
forty_facets-0.1.2 lib/forty_facets/order_definition.rb
forty_facets-0.1.1 lib/forty_facets/order_definition.rb
forty_facets-0.1.0 lib/forty_facets/order_definition.rb
forty_facets-0.0.14 lib/forty_facets/order_definition.rb
forty_facets-0.0.13 lib/forty_facets/order_definition.rb