Sha256: 84384068821985b4d438a15da29b53e964e3d310ebb08c651c71f53f57cb18fb
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
module FortyFacets class ScopeFilterDefinition < FilterDefinition class ScopeFilter < Filter def active? definition.options[:pass_value] ? value.present? : value == '1' end def selected [value] end def build_scope return proc { |base| base } unless active? proc { |base| if definition.options[:pass_value] base.send(definition.path.first, value) else base.send(definition.path.first) end } end # added value to standardize the API even though it's not used def remove(value = nil) new_params = search_instance.params || {} new_params.delete(definition.request_param) search_instance.class.new_unwrapped(new_params, search_instance.root) end def add(value = '1') new_params = search_instance.params || {} new_params[definition.request_param] = value search_instance.class.new_unwrapped(new_params, search_instance.root) end end def build_filter(search_instance, value) ScopeFilter.new(self, search_instance, value) end end end
Version data entries
4 entries across 4 versions & 1 rubygems