Class: Scatter::Remote
- Inherits:
-
Object
- Object
- Scatter::Remote
- Defined in:
- lib/scatter/remote.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Class Method Summary collapse
Instance Method Summary collapse
- #encode_for_config ⇒ Object
- #find_node(name) ⇒ Object
-
#initialize(name) ⇒ Remote
constructor
A new instance of Remote.
- #push(gemfile) ⇒ Object
Constructor Details
#initialize(name) ⇒ Remote
Returns a new instance of Remote.
5 6 7 8 |
# File 'lib/scatter/remote.rb', line 5 def initialize(name) @name = name @nodes = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/scatter/remote.rb', line 3 def name @name end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
3 4 5 |
# File 'lib/scatter/remote.rb', line 3 def nodes @nodes end |
Class Method Details
.decode_from_config(name, config) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/scatter/remote.rb', line 20 def self.decode_from_config(name, config) remote = new(name) nodes = config['nodes'].collect { |nodename, config| Node.decode_from_config(remote, nodename, config) } rescue [] remote.nodes.concat(nodes) remote end |
Instance Method Details
#encode_for_config ⇒ Object
27 28 29 30 31 |
# File 'lib/scatter/remote.rb', line 27 def encode_for_config { 'nodes' => @nodes.inject({}) { |hash, node| hash[node.name] = node.encode_for_config; hash } } end |
#find_node(name) ⇒ Object
16 17 18 |
# File 'lib/scatter/remote.rb', line 16 def find_node(name) nodes.find { |node| node.name == name } end |
#push(gemfile) ⇒ Object
10 11 12 13 14 |
# File 'lib/scatter/remote.rb', line 10 def push(gemfile) @nodes.each do |node| node.push(gemfile) end end |