Class: Mnemosyne::Configuration
- Inherits:
-
Object
- Object
- Mnemosyne::Configuration
- Defined in:
- lib/mnemosyne/configuration.rb
Instance Attribute Summary collapse
-
#amqp ⇒ Object
readonly
Returns the value of attribute amqp.
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(config) ⇒ Configuration
constructor
rubocop:disable Metrics/AbcSize.
Constructor Details
#initialize(config) ⇒ Configuration
rubocop:disable Metrics/AbcSize
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mnemosyne/configuration.rb', line 17 def initialize(config) @platform = config.fetch('platform', 'default').to_s.strip.freeze @application = config.fetch('application', nil).to_s.strip.freeze @enabled = config.fetch('enabled', true) @hostname = config.fetch('hostname') { default_hostname }.to_s.strip.freeze @exchange = config.fetch('exchange', 'mnemosyne').to_s.freeze @logger = config.fetch('logger') { Logger.new($stdout) } server = config.fetch('server', 'amqp://localhost') @amqp = AMQ::Settings.configure(server).freeze @server = make_amqp_uri(@amqp).to_s.freeze raise ArgumentError.new('Application is required') if application.blank? raise ArgumentError.new('Hostname is required') if hostname.blank? end |
Instance Attribute Details
#amqp ⇒ Object (readonly)
Returns the value of attribute amqp.
11 12 13 |
# File 'lib/mnemosyne/configuration.rb', line 11 def amqp @amqp end |
#application ⇒ Object (readonly)
Returns the value of attribute application.
8 9 10 |
# File 'lib/mnemosyne/configuration.rb', line 8 def application @application end |
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
12 13 14 |
# File 'lib/mnemosyne/configuration.rb', line 12 def exchange @exchange end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
9 10 11 |
# File 'lib/mnemosyne/configuration.rb', line 9 def hostname @hostname end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/mnemosyne/configuration.rb', line 13 def logger @logger end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
10 11 12 |
# File 'lib/mnemosyne/configuration.rb', line 10 def platform @platform end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
14 15 16 |
# File 'lib/mnemosyne/configuration.rb', line 14 def server @server end |
Instance Method Details
#enabled? ⇒ Boolean
33 34 35 |
# File 'lib/mnemosyne/configuration.rb', line 33 def enabled? @enabled end |