Module: ClassyFilter::ClassMethods
- Included in:
- Base
- Defined in:
- lib/classy_filter/class_methods.rb
Instance Attribute Summary collapse
-
#filter_fields ⇒ Object
readonly
Returns the value of attribute filter_fields.
Instance Method Summary collapse
- #coercion(name, body) ⇒ Object
- #coercions_module ⇒ Object
- #filter_field(param_name, attribute: nil, predicate: :eq_in, coercion: nil) ⇒ Object
- #predicate(name, body) ⇒ Object
- #predicates_module ⇒ Object
Instance Attribute Details
#filter_fields ⇒ Object (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.private(name) end |
#coercions_module ⇒ Object
25 26 27 |
# File 'lib/classy_filter/class_methods.rb', line 25 def coercions_module @coercions_module || ClassyFilter::Coercions 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 |
#predicates_module ⇒ Object
21 22 23 |
# File 'lib/classy_filter/class_methods.rb', line 21 def predicates_module @predicates_module || ClassyFilter::Predicates end |