Module: ClassyFilter::ClassMethods

Included in:
Base
Defined in:
lib/classy_filter/class_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filter_fieldsObject (readonly)

Returns the value of attribute filter_fields.



3
4
5
# File 'lib/classy_filter/class_methods.rb', line 3

def filter_fields
  @filter_fields
end

Instance Method Details

#coercion(name, body) ⇒ Object



16
17
18
19
# File 'lib/classy_filter/class_methods.rb', line 16

def coercion(name, body)
  coercions_module.define_method(name, &body)
  coercions_module.send(:private, name)
end

#filter_field(param_name, attribute: nil, predicate: :eq_in, coercion: nil) ⇒ Object



5
6
7
8
9
10
# File 'lib/classy_filter/class_methods.rb', line 5

def filter_field(param_name, attribute: nil,
                 predicate: :eq_in, coercion: nil)
  @filter_fields ||= []
  @filter_fields << Field.new(param_name, attribute,
                              predicate, coercion)
end

#predicate(name, body) ⇒ Object



12
13
14
# File 'lib/classy_filter/class_methods.rb', line 12

def predicate(name, body)
  predicates_module.define_method(name, &body)
end