Module: Orchestration::Services::ConfigurationBase
- Included in:
- App::Configuration, Database::Configuration, Listener::Configuration, Mongo::Configuration, RabbitMQ::Configuration
- Defined in:
- lib/orchestration/services/mixins/configuration_base.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Class Method Summary collapse
Instance Method Summary collapse
- #configured? ⇒ Boolean
- #host ⇒ Object
- #initialize(env, service_name = nil) ⇒ Object
- #port ⇒ Object
- #yaml(content) ⇒ Object
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
6 7 8 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 6 def env @env end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
6 7 8 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 6 def error @error end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
6 7 8 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 6 def service_name @service_name end |
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 8 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#configured? ⇒ Boolean
36 37 38 39 40 41 42 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 36 def configured? port true rescue KeyError => error @error = error false end |
#host ⇒ Object
30 31 32 33 34 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 30 def host return '127.0.0.1' if %w[test development].include?(@env.environment) @service_name end |
#initialize(env, service_name = nil) ⇒ Object
25 26 27 28 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 25 def initialize(env, service_name = nil) @env = env @service_name = service_name || self.class.service_name end |
#port ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 44 def port return @env.app_port if @service_name == 'app' local, _, remote = @env.docker_compose_config .fetch('services') .fetch(@service_name) .fetch('ports') .first .partition(':') (@env.environment == 'production' ? remote : local).to_i end |
#yaml(content) ⇒ Object
57 58 59 60 |
# File 'lib/orchestration/services/mixins/configuration_base.rb', line 57 def yaml(content) # Whitelist `Symbol` and permit aliases: YAML.safe_load(content, [Symbol], [], true) end |