Class: JsonApiFilter::CustomFilter
- Inherits:
-
Object
- Object
- JsonApiFilter::CustomFilter
- Defined in:
- lib/json_api_filter/custom_filter.rb
Constant Summary collapse
- OPERATORS =
%i[eq ne gt ge lt le].freeze
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
- #handler_for(operator) ⇒ Object
-
#initialize(&definition) ⇒ CustomFilter
constructor
A new instance of CustomFilter.
Constructor Details
#initialize(&definition) ⇒ CustomFilter
Returns a new instance of CustomFilter.
7 8 9 10 11 12 |
# File 'lib/json_api_filter/custom_filter.rb', line 7 def initialize(&definition) @handlers = {} instance_eval(&definition) @handlers.freeze freeze end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
5 6 7 |
# File 'lib/json_api_filter/custom_filter.rb', line 5 def handlers @handlers end |
Instance Method Details
#handler_for(operator) ⇒ Object
20 21 22 |
# File 'lib/json_api_filter/custom_filter.rb', line 20 def handler_for(operator) handlers[operator.to_s] end |