Module: Peplum::Application::Payload
- Defined in:
- lib/peplum/application/payload.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
-
#merge(data) ⇒ Object
Merge result ‘data` for reporting.
-
#run(objects, options) ⇒ Object
abstract
Run payload against ‘objects` based on given `options`.
-
#split(objects, groups_of) ⇒ Array<Array<Object>>
Distribute ‘objects` into `groups_of` amount of groups, one for each worker.
Instance Method Details
#merge(data) ⇒ Object
Merge result ‘data` for reporting.
By default provides a generic implementation that merges the values of ‘Hash`es and `Array`s. If `String`s or `Numeric`s are contained, the Array is returned as is.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/peplum/application/payload.rb', line 40 def merge( data ) case data.first when Hash f = data.pop data.each do |d| if !f.is_a? Hash fail Error::ImplementationMissing, 'Missing implementation: Item not a Hash!' end f.merge! d end f when Array data.flatten when String, Numeric data else fail Error::ImplementationMissing, 'Missing implementation.' end end |
#run(objects, options) ⇒ Object
This method is abstract.
Run payload against ‘objects` based on given `options`
17 18 19 |
# File 'lib/peplum/application/payload.rb', line 17 def run( objects, ) fail Error::ImplementationMissing, 'Missing implementation.' end |