Module: Queryko::Able::ClassMethods

Defined in:
lib/queryko/able.rb

Instance Method Summary collapse

Instance Method Details

#feature(feature_name, filter, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/queryko/able.rb', line 18

def feature(feature_name, filter, options = {})
  # returns the feature if it exists
  feat = self.features[feature_name.to_sym] ||= Queryko::Feature.new feature_name, self
  self.defined_filters[filter] ||= Array.new

  # creates a filter
  filt = feat.add_filter filter, options
  self.defined_filters[filter].push(filt)

  # appends new field
  self.fields[filt.field.to_sym] ||= Array.new
  self.fields[filt.field.to_sym].push(filt)
end