Class: Floe::Workflow::ItemBatcher
- Inherits:
-
Object
- Object
- Floe::Workflow::ItemBatcher
- Includes:
- ValidationMixin
- Defined in:
- lib/floe/workflow/item_batcher.rb
Instance Attribute Summary collapse
-
#batch_input ⇒ Object
readonly
Returns the value of attribute batch_input.
-
#max_input_bytes_per_batch ⇒ Object
readonly
Returns the value of attribute max_input_bytes_per_batch.
-
#max_input_bytes_per_batch_path ⇒ Object
readonly
Returns the value of attribute max_input_bytes_per_batch_path.
-
#max_items_per_batch ⇒ Object
readonly
Returns the value of attribute max_items_per_batch.
-
#max_items_per_batch_path ⇒ Object
readonly
Returns the value of attribute max_items_per_batch_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(payload, name) ⇒ ItemBatcher
constructor
A new instance of ItemBatcher.
- #value(context, input, state_input = nil) ⇒ Object
Methods included from ValidationMixin
included, #invalid_field_error!, #missing_field_error!, #parser_error!, #runtime_field_error!, #wrap_parser_error
Constructor Details
#initialize(payload, name) ⇒ ItemBatcher
Returns a new instance of ItemBatcher.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/floe/workflow/item_batcher.rb', line 10 def initialize(payload, name) @name = name @batch_input = PayloadTemplate.new(payload["BatchInput"]) if payload["BatchInput"] @max_items_per_batch = payload["MaxItemsPerBatch"] @max_input_bytes_per_batch = payload["MaxInputBytesPerBatch"] @max_items_per_batch_path = ReferencePath.new(payload["MaxItemsPerBatchPath"]) if payload["MaxItemsPerBatchPath"] @max_input_bytes_per_batch_path = ReferencePath.new(payload["MaxInputBytesPerBatchPath"]) if payload["MaxInputBytesPerBatchPath"] validate! end |
Instance Attribute Details
#batch_input ⇒ Object (readonly)
Returns the value of attribute batch_input.
8 9 10 |
# File 'lib/floe/workflow/item_batcher.rb', line 8 def batch_input @batch_input end |
#max_input_bytes_per_batch ⇒ Object (readonly)
Returns the value of attribute max_input_bytes_per_batch.
8 9 10 |
# File 'lib/floe/workflow/item_batcher.rb', line 8 def max_input_bytes_per_batch @max_input_bytes_per_batch end |
#max_input_bytes_per_batch_path ⇒ Object (readonly)
Returns the value of attribute max_input_bytes_per_batch_path.
8 9 10 |
# File 'lib/floe/workflow/item_batcher.rb', line 8 def max_input_bytes_per_batch_path @max_input_bytes_per_batch_path end |
#max_items_per_batch ⇒ Object (readonly)
Returns the value of attribute max_items_per_batch.
8 9 10 |
# File 'lib/floe/workflow/item_batcher.rb', line 8 def max_items_per_batch @max_items_per_batch end |
#max_items_per_batch_path ⇒ Object (readonly)
Returns the value of attribute max_items_per_batch_path.
8 9 10 |
# File 'lib/floe/workflow/item_batcher.rb', line 8 def max_items_per_batch_path @max_items_per_batch_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/floe/workflow/item_batcher.rb', line 8 def name @name end |
Instance Method Details
#value(context, input, state_input = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/floe/workflow/item_batcher.rb', line 23 def value(context, input, state_input = nil) state_input ||= input output = batch_input ? batch_input.value(context, state_input) : {} input.each_slice(max_items(context, state_input)).map do |batch| output.merge("Items" => batch) end end |