Sha256: 39e3bb7c546664cc0677d57e1fd2c59ac311972670ce428925b241224d8ef454
Contents?: true
Size: 813 Bytes
Versions: 1
Compression:
Stored size: 813 Bytes
Contents
require 'active_support/hash_with_indifferent_access' require 'livelist/rails/filter' module Livelist module Rails class FilterCollection < HashWithIndifferentAccess alias :filters :values alias :find_filter :[] def create_filter(options) options.merge!(:filter_collection => self) self[options[:slug]] = Filter.new(options) end def relation(query, params) params ||= {} filters.each do |filter| query = filter.relation(query, params[filter.slug.to_s], params.empty?) end query end def as_json(query, params) params ||= {} filters.map do |filter| filter.set_criteria_counts(query, params) filter.as_json(params[filter.slug]) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
livelist-rails-0.0.11 | lib/livelist/rails/filter_collection.rb |