Class: Hoth::ServiceModule
- Inherits:
-
Object
- Object
- Hoth::ServiceModule
- Defined in:
- lib/hoth/service_module.rb
Defined Under Namespace
Classes: Environment
Instance Attribute Summary collapse
-
#environments ⇒ Object
Returns the value of attribute environments.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #[](env_name) ⇒ Object
- #add_service(service_name, options = {}) ⇒ Object
- #env(*env_names, &block) ⇒ Object
-
#initialize(attributes = {}) ⇒ ServiceModule
constructor
A new instance of ServiceModule.
Constructor Details
#initialize(attributes = {}) ⇒ ServiceModule
Returns a new instance of ServiceModule.
22 23 24 25 |
# File 'lib/hoth/service_module.rb', line 22 def initialize(attributes = {}) @environments = {} @name = attributes[:name] end |
Instance Attribute Details
#environments ⇒ Object
Returns the value of attribute environments.
3 4 5 |
# File 'lib/hoth/service_module.rb', line 3 def environments @environments end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/hoth/service_module.rb', line 3 def name @name end |
Instance Method Details
#[](env_name) ⇒ Object
44 45 46 |
# File 'lib/hoth/service_module.rb', line 44 def [](env_name) @environments[env_name.to_sym] end |
#add_service(service_name, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hoth/service_module.rb', line 33 def add_service(service_name, = {}) raise HothException.new("no endpoint-definition for environment '#{Hoth.env}' and service '#{service_name}'") unless self.environments[Hoth.env] service = ServiceRegistry.locate_service(service_name.to_sym) raise HothException.new("tried to add service '#{service_name}' but was not defined by service-definition") unless service service.module = self service.via_endpoint([:via]) end |
#env(*env_names, &block) ⇒ Object
27 28 29 30 31 |
# File 'lib/hoth/service_module.rb', line 27 def env(*env_names, &block) env_names.each do |env_name| @environments[env_name.to_sym] = Environment.new(&block) end end |