Sha256: 0107cfd0e5075a76674621745324abdcb0517309f45bc183b73ec7629f3cf424

Contents?: true

Size: 557 Bytes

Versions: 1

Compression:

Stored size: 557 Bytes

Contents

module Georgia
  class ActiveFacetPresenter < Presenter

    attr_reader :text, :param

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

    def to_s
      link_to url_for(unmerged_params), class: 'label label-primary' do
        "#{text} #{icon_tag('times')}".html_safe
      end
    end

    private

    def unmerged_params
      facets = (params[param] || []) - [text]
      facets.any? ? params.merge(param => facets) : params.except(param)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.8.0 app/presenters/georgia/active_facet_presenter.rb