Class: Resourcey::FilterProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/resourcey/filter_processor.rb

Constant Summary collapse

ALLOWED_OPTIONS =
%i[multivalue].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}, &block) ⇒ FilterProcessor

Returns a new instance of FilterProcessor.



7
8
9
10
11
12
13
# File 'lib/resourcey/filter_processor.rb', line 7

def initialize(name, opts = {}, &block)
  @name = name.to_s
  @opts = opts
  @block = block

  validate_options!
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/resourcey/filter_processor.rb', line 5

def name
  @name
end

Instance Method Details

#apply(permitted_param, scope) ⇒ Object



15
16
17
18
# File 'lib/resourcey/filter_processor.rb', line 15

def apply(permitted_param, scope)
  filter_value = parse_filter_value(permitted_param)
  block.call(filter_value, scope)
end