Sha256: 65eaffbb5b73bd7d34761538465b43ec3f6a1941630ac74bfa5ba8ad1c4253e6

Contents?: true

Size: 405 Bytes

Versions: 5

Compression:

Stored size: 405 Bytes

Contents

module FortyFacets
  # Represents the ordering for a specific search
  Order = Struct.new(:search, :definition, :active) do
    def title
      definition.title
    end

    # Returns a search with the same filter ordered by this criteria
    def by
      new_params = search.params || {}
      new_params[:order] = definition.request_value
      search.class.new_unwrapped(new_params)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
forty_facets-0.0.8 lib/forty_facets/order.rb
forty_facets-0.0.7 lib/forty_facets/order.rb
forty_facets-0.0.6 lib/forty_facets/order.rb
forty_facets-0.0.5 lib/forty_facets/order.rb
forty_facets-0.0.4 lib/forty_facets/order.rb