Sha256: 52f179ae61e549868e8007a8bc399840b2b8327c5eead7caefff7da1f44a6562
Contents?: true
Size: 1.34 KB
Versions: 9
Compression:
Stored size: 1.34 KB
Contents
module Hoth class ServiceModule class Environment attr_accessor :endpoints def initialize(&block) @endpoints = {} instance_eval(&block) end def endpoint(endpoint_name, &block) @endpoints[endpoint_name.to_sym] = Endpoint.new(&block) end def [](endpoint_name) @endpoints[endpoint_name.to_sym] end end attr_accessor :name, :environments, :registered_services def initialize(attributes = {}) @environments = {} @registered_services = [] @name = attributes[:name] end def env(*env_names, &block) env_names.each do |env_name| @environments[env_name.to_sym] = Environment.new(&block) end end def add_service(service_name, options = {}) 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(options[:via]) @registered_services << service end def [](env_name) @environments[env_name.to_sym] end end end
Version data entries
9 entries across 9 versions & 1 rubygems