Class: Burner::Library::Collection::OnlyKeys

Inherits:
JobWithDynamicKeys show all
Defined in:
lib/burner/library/collection/only_keys.rb

Overview

This job knows how to take an array of objects and limit it to a specific set of keys. The keys are pulled from another register which helps make it dynamic (you can load up this other register with a dynamic list of keys at run-time.)

Expected Payload input: array of objects. Payload output: An array of objects.

Constant Summary

Constants inherited from JobWithRegister

JobWithRegister::BLANK

Instance Attribute Summary

Attributes inherited from JobWithDynamicKeys

#key_mappings, #keys_register, #resolver

Attributes inherited from JobWithRegister

#register

Attributes inherited from Job

#name

Instance Method Summary collapse

Methods inherited from JobWithDynamicKeys

#initialize

Methods inherited from JobWithRegister

#initialize

Methods inherited from Job

#initialize

Methods included from Util::Arrayable

#array

Constructor Details

This class inherits a constructor from Burner::JobWithDynamicKeys

Instance Method Details

#perform(output, payload) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/burner/library/collection/only_keys.rb', line 20

def perform(output, payload)
  objects = array(payload[register])
  count   = objects.length
  keys    = array(payload[keys_register])

  output.detail("Dynamically limiting #{count} object(s) with key(s): #{keys.join(', ')}")

  payload[register] = objects.map { |object| transform(object, keys) }
end