Class: JsonApiFilter::CustomFilter

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#handlersObject (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