Class: Apill::Resource::Processors::Filtering
- Inherits:
-
Object
- Object
- Apill::Resource::Processors::Filtering
- Defined in:
- lib/apill/resource/processors/filtering.rb
Instance Attribute Summary collapse
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#resource ⇒ Object
Returns the value of attribute resource.
Class Method Summary collapse
- .meta(*_attrs) ⇒ Object
-
.processed(*attrs) ⇒ Object
rubocop:enable Style/OptionHash.
Instance Method Summary collapse
-
#initialize(resource, parameters = {}) ⇒ Filtering
constructor
rubocop:disable Style/OptionHash.
- #processed ⇒ Object
Constructor Details
#initialize(resource, parameters = {}) ⇒ Filtering
rubocop:disable Style/OptionHash
11 12 13 14 |
# File 'lib/apill/resource/processors/filtering.rb', line 11 def initialize(resource, parameters = {}) self.resource = resource self.parameters = Parameters::Filter.new(parameters['filter'] || {}) end |
Instance Attribute Details
#parameters ⇒ Object
Returns the value of attribute parameters.
7 8 9 |
# File 'lib/apill/resource/processors/filtering.rb', line 7 def parameters @parameters end |
#resource ⇒ Object
Returns the value of attribute resource.
7 8 9 |
# File 'lib/apill/resource/processors/filtering.rb', line 7 def resource @resource end |
Class Method Details
.meta(*_attrs) ⇒ Object
21 22 23 |
# File 'lib/apill/resource/processors/filtering.rb', line 21 def self.(*_attrs) {} end |
.processed(*attrs) ⇒ Object
rubocop:enable Style/OptionHash
17 18 19 |
# File 'lib/apill/resource/processors/filtering.rb', line 17 def self.processed(*attrs) new(*attrs).processed end |
Instance Method Details
#processed ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/apill/resource/processors/filtering.rb', line 25 def processed parameters.each_with_object(resource) do |name, value, filtered_resource| filter_method = filter_method_for(name) if !filter_method filtered_resource elsif filter_method.arity == 0 filtered_resource.public_send(filter_method.name) else filtered_resource.public_send(filter_method.name, value) end end end |