Module: Refinuri::Helpers
- Included in:
- Refinuri
- Defined in:
- lib/refinuri/helpers.rb
Instance Method Summary collapse
- #filter_with_link(name, filters, options = nil, html_options = nil) ⇒ Object
-
#toggle_filter_with_link(name, toggle_filter, options = nil, html_options = nil) ⇒ Object
TODO needs to get cleaned up.
Instance Method Details
#filter_with_link(name, filters, options = nil, html_options = nil) ⇒ Object
3 4 5 6 7 |
# File 'lib/refinuri/helpers.rb', line 3 def filter_with_link(name, filters, = nil, = nil) = || params [:filters] = @filters.merge!(filters).to_url link_to(name,,) end |
#toggle_filter_with_link(name, toggle_filter, options = nil, html_options = nil) ⇒ Object
TODO needs to get cleaned up
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/refinuri/helpers.rb', line 10 def toggle_filter_with_link(name, toggle_filter, = nil, = nil) = || params key_to_toggle = toggle_filter.first[0] if @filters.filters[key_to_toggle] crud = case @filters.filters[key_to_toggle].value when Array then (@filters.filters[key_to_toggle].value.include?(toggle_filter.first[1]) ? :delete : :update) else :delete end else crud = :update end [:filters] = @filters.merge!({ crud => toggle_filter }).to_url link_to(name,,) end |