Class: Bork::Environment
- Inherits:
-
Object
- Object
- Bork::Environment
- Defined in:
- lib/bork/environment.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#servers ⇒ Object
Returns the value of attribute servers.
Instance Method Summary collapse
- #build! ⇒ Object
-
#initialize(name, *options, &block) ⇒ Environment
constructor
A new instance of Environment.
- #restore! ⇒ Object
-
#server(role, &block) ⇒ Object
DSL Method.
- #setup! ⇒ Object
Constructor Details
#initialize(name, *options, &block) ⇒ Environment
Returns a new instance of Environment.
5 6 7 8 9 10 |
# File 'lib/bork/environment.rb', line 5 def initialize(name, *, &block) @name = name.to_sym @servers = {} instance_eval &block end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bork/environment.rb', line 3 def name @name end |
#servers ⇒ Object
Returns the value of attribute servers.
3 4 5 |
# File 'lib/bork/environment.rb', line 3 def servers @servers end |
Instance Method Details
#build! ⇒ Object
19 20 21 22 23 |
# File 'lib/bork/environment.rb', line 19 def build! @servers.each do |role,server| server.bootstrap! end end |
#restore! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/bork/environment.rb', line 25 def restore! link_provider @servers.select { |role,server| !server.linked? }.each do |role,server| raise Bork::ServerNotFoundError end end |
#server(role, &block) ⇒ Object
DSL Method
13 14 15 16 17 |
# File 'lib/bork/environment.rb', line 13 def server(role, &block) require 'bork/server' @servers[role] = Bork::Server.new(role, :environment => self, &block) end |
#setup! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bork/environment.rb', line 32 def setup! link_provider @servers.select { |role,server| !server.linked? }.each do |role,server| Bork.logger.info(role.to_s) { "Existing instance not found, bootstrapping" } server.bootstrap! end @servers.each do |role, server| server.setup! end end |