Class: Burner::Library::Collection::Graph
- Inherits:
-
JobWithRegister
- Object
- Job
- JobWithRegister
- Burner::Library::Collection::Graph
- Defined in:
- lib/burner/library/collection/graph.rb
Overview
Take an array of (denormalized) objects and create an object hierarchy from them. Under the hood it uses Hashematics: github.com/bluemarblepayroll/hashematics.
Expected Payload input: array of objects. Payload output: An array of objects.
Constant Summary
Constants inherited from JobWithRegister
Instance Attribute Summary collapse
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Attributes inherited from JobWithRegister
Attributes inherited from Job
Instance Method Summary collapse
-
#initialize(key:, config: Hashematics::Configuration.new, name: '', register: DEFAULT_REGISTER) ⇒ Graph
constructor
A new instance of Graph.
- #perform(output, payload) ⇒ Object
Methods included from Util::Arrayable
Constructor Details
#initialize(key:, config: Hashematics::Configuration.new, name: '', register: DEFAULT_REGISTER) ⇒ Graph
Returns a new instance of Graph.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/burner/library/collection/graph.rb', line 21 def initialize( key:, config: Hashematics::Configuration.new, name: '', register: DEFAULT_REGISTER ) super(name: name, register: register) raise ArgumentError, 'key is required' if key.to_s.empty? @groups = Hashematics::Configuration.new(config).groups @key = key.to_s freeze end |
Instance Attribute Details
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
19 20 21 |
# File 'lib/burner/library/collection/graph.rb', line 19 def groups @groups end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
19 20 21 |
# File 'lib/burner/library/collection/graph.rb', line 19 def key @key end |
Instance Method Details
#perform(output, payload) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/burner/library/collection/graph.rb', line 37 def perform(output, payload) graph = Hashematics::Graph.new(groups).add(array(payload[register])) output.detail("Graphing: #{key}") payload[register] = graph.data(key) end |