module PassionView::Filterable
Attributes
filters[R]
Public Class Methods
new(items, options = {})
click to toggle source
Calls superclass method
# File lib/passion_view/filterable.rb, line 4 def initialize(items, options = {}) super filters = filters_default.merge(options.delete(:filters) || {}) filter_with(filters) end
Public Instance Methods
filter_path()
click to toggle source
# File lib/passion_view/filterable.rb, line 17 def filter_path url_options end
items()
click to toggle source
Calls superclass method
# File lib/passion_view/filterable.rb, line 11 def items filters.reduce(super) do |items, filter| filter.skip? ? items : filter.apply(items) end end
Private Instance Methods
filter_with(_)
click to toggle source
# File lib/passion_view/filterable.rb, line 37 def filter_with(_) @filters ||= FilterList.new end
filterable_params()
click to toggle source
# File lib/passion_view/filterable.rb, line 33 def filterable_params filters.each.with_object(filters: {}) { |filter, params| params[:filters][filter.name.to_sym] = filter.value unless filter.skip? } end
filters_default()
click to toggle source
# File lib/passion_view/filterable.rb, line 25 def filters_default {} end
url_options()
click to toggle source
Calls superclass method
# File lib/passion_view/filterable.rb, line 29 def url_options super.merge(filterable_params) end