Sha256: 3ccd278af4c9e434f8a86899c69b226a5490aff9632097162028bc6e74d99da2

Contents?: true

Size: 673 Bytes

Versions: 8

Compression:

Stored size: 673 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.merge(param => ((params[param] || []) + [text]))
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
georgia-0.7.7 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.6 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.5 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.4 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.3 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.2 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.1 app/presenters/georgia/list_facet_presenter.rb
georgia-0.7.0 app/presenters/georgia/list_facet_presenter.rb