Class: Pyper::Pipes::RemoveFields
- Inherits:
-
Object
- Object
- Pyper::Pipes::RemoveFields
- Defined in:
- lib/pyper/pipes/remove_fields.rb
Overview
A generic pipe to remove fields from a pipeline
Instance Attribute Summary collapse
-
#fields_to_remove ⇒ Object
readonly
Returns the value of attribute fields_to_remove.
Instance Method Summary collapse
-
#initialize(fields_to_remove) ⇒ RemoveFields
constructor
A new instance of RemoveFields.
-
#pipe(attributes, status = {}) ⇒ Hash
Attributes with the specified fields removed.
Constructor Details
#initialize(fields_to_remove) ⇒ RemoveFields
Returns a new instance of RemoveFields.
8 9 10 |
# File 'lib/pyper/pipes/remove_fields.rb', line 8 def initialize(fields_to_remove) @fields_to_remove = Array.wrap(fields_to_remove) end |
Instance Attribute Details
#fields_to_remove ⇒ Object (readonly)
Returns the value of attribute fields_to_remove.
5 6 7 |
# File 'lib/pyper/pipes/remove_fields.rb', line 5 def fields_to_remove @fields_to_remove end |
Instance Method Details
#pipe(attributes, status = {}) ⇒ Hash
Returns attributes with the specified fields removed.
15 16 17 18 19 20 |
# File 'lib/pyper/pipes/remove_fields.rb', line 15 def pipe(attributes, status = {}) attributes = attributes.dup fields_to_remove.each { |field| attributes.delete(field) } attributes end |