Sha256: 91f854fc02320d2cfc7c57481b6860bfe6fe3002f90523618f00ff206898d00f

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 Bytes

Contents

module Georgia
  class ListFacetPresenter < Presenter

    attr_reader :list, :param, :options

    def initialize view_context, list, param, options={}
      super
      @list = list
      @param = param
      @options = options
    end

    def to_s
      output = ActiveSupport::SafeBuffer.new
      list.each do |text|
        output << link_to(text, url_for(merged_params(text)), class: 'label label-default') unless active?(text)
      end
      output
    end

    private

    def active?(text)
      params[param] and params[param].include?(text)
    end

    def merged_params(text)
      params.reject{|k,v| k == 'page'}.merge(param => ((params[param] || []) + [text]))
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
georgia-0.8.0 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.8 app/presenters/georgia/list_facet_presenter.rb