Class: Woodhouse::LayoutSerializer::LayoutLoader
- Inherits:
-
Object
- Object
- Woodhouse::LayoutSerializer::LayoutLoader
- Defined in:
- lib/woodhouse/layout_serializer.rb
Instance Method Summary collapse
-
#initialize(json) ⇒ LayoutLoader
constructor
A new instance of LayoutLoader.
- #layout ⇒ Object
Constructor Details
#initialize(json) ⇒ LayoutLoader
Returns a new instance of LayoutLoader.
29 30 31 |
# File 'lib/woodhouse/layout_serializer.rb', line 29 def initialize(json) @entries = JSON.parse(json) end |
Instance Method Details
#layout ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/woodhouse/layout_serializer.rb', line 33 def layout Woodhouse::Layout.new.tap do |layout| @entries['nodes'].each do |node| new_node = layout.add_node(node['name']) node['workers'].each do |worker| new_node.add_worker Woodhouse::Layout::Worker.new(worker['worker_class_name'], worker['job_method'], :threads => worker['threads'], :only => worker['criteria']) end end end end |