Class: Bcome::Node::Base
- Includes:
- CommandHelper
- Defined in:
- lib/nodes/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#meta_data ⇒ Object
readonly
Returns the value of attribute meta_data.
Instance Method Summary collapse
-
#initialize(meta_data) ⇒ Base
constructor
A new instance of Base.
- #machines ⇒ Object
- #method_missing(method_sym, *arguments, &block) ⇒ Object
-
#run(raw_command, bootstrap = false) ⇒ Object
Runs a command over every machine in this node.
- #set_parent_reference(parent, parent_reference_key, collection_key) ⇒ Object
Methods included from CommandHelper
Constructor Details
#initialize(meta_data) ⇒ Base
Returns a new instance of Base.
12 13 14 |
# File 'lib/nodes/base.rb', line 12 def initialize() construct() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/nodes/base.rb', line 25 def method_missing(method_sym, *arguments, &block) if instance_variable_defined?("@#{method_sym}") return instance_variable_get("@#{method_sym}") else super end end |
Instance Attribute Details
#meta_data ⇒ Object (readonly)
Returns the value of attribute meta_data.
6 7 8 |
# File 'lib/nodes/base.rb', line 6 def @meta_data end |
Instance Method Details
#machines ⇒ Object
8 9 10 |
# File 'lib/nodes/base.rb', line 8 def machines raise "Should be overriden" end |
#run(raw_command, bootstrap = false) ⇒ Object
Runs a command over every machine in this node
17 18 19 20 21 22 23 |
# File 'lib/nodes/base.rb', line 17 def run(raw_command, bootstrap = false) return unless machines machines.pmap {|machine| machine.run([raw_command], bootstrap) } return end |
#set_parent_reference(parent, parent_reference_key, collection_key) ⇒ Object
33 34 35 36 37 |
# File 'lib/nodes/base.rb', line 33 def set_parent_reference(parent, parent_reference_key, collection_key) instance_variable_get("@#{collection_key}").map{|collection_item| collection_item.instance_variable_set("@#{parent_reference_key}", parent) } end |