Class: Burner::Library::Collection::Values
- Inherits:
-
JobWithRegister
- Object
- Job
- JobWithRegister
- Burner::Library::Collection::Values
- Defined in:
- lib/burner/library/collection/values.rb
Overview
Constant Summary
Constants inherited from JobWithRegister
Instance Attribute Summary collapse
-
#include_keys ⇒ Object
readonly
Returns the value of attribute include_keys.
Attributes inherited from JobWithRegister
Attributes inherited from Job
Instance Method Summary collapse
-
#initialize(include_keys: false, name: '', register: DEFAULT_REGISTER) ⇒ Values
constructor
A new instance of Values.
- #perform(_output, payload) ⇒ Object
Methods included from Util::Arrayable
Constructor Details
#initialize(include_keys: false, name: '', register: DEFAULT_REGISTER) ⇒ Values
Returns a new instance of Values.
22 23 24 25 26 27 28 |
# File 'lib/burner/library/collection/values.rb', line 22 def initialize(include_keys: false, name: '', register: DEFAULT_REGISTER) super(name: name, register: register) @include_keys = include_keys || false freeze end |
Instance Attribute Details
#include_keys ⇒ Object (readonly)
Returns the value of attribute include_keys.
20 21 22 |
# File 'lib/burner/library/collection/values.rb', line 20 def include_keys @include_keys end |
Instance Method Details
#perform(_output, payload) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/burner/library/collection/values.rb', line 30 def perform(_output, payload) payload[register] = array(payload[register]) keys = include_keys ? [keys(payload[register].first)] : [] values = payload[register].map { |object| values(object) } payload[register] = keys + values end |