Class: Carioca::Services::Configuration

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbUndumped
Defined in:
lib/carioca/services/configuration.rb

Overview

Service Configuration of Carioca

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_opts = {}) ⇒ Configuration

Configuration service constructor (open config)

Parameters:

  • _options (Hash)

    the params



140
141
142
143
144
145
146
147
# File 'lib/carioca/services/configuration.rb', line 140

def initialize(_opts = {})


  options = Methodic.get_options(_opts)
  options.specify_default_value :config_file => "./.config"
  options.merge
  @settings = Carioca::Services::Settings.new(options)
end

Instance Attribute Details

#settingsObject

Examples:

config = Carioca::Services::Configuration::new :config_file => 'afilename', :context => 'production'
p config.config_file
config_file = 'newfilename'


134
135
136
# File 'lib/carioca/services/configuration.rb', line 134

def settings
  @settings
end

Instance Method Details

#config_fileString

reading wrapper to @settings.config_file accessor

Examples:

usage

config = Carioca::Services::Configuration::new :config_file => 'afilename', :context => 'production'
p config.config_file

Returns:

  • (String)

    @config_file the file name



166
167
168
# File 'lib/carioca/services/configuration.rb', line 166

def config_file
  @settings.config_file
end

#config_file=(name) ⇒ Object

writting wrapper to @settings.config_file accessor

Examples:

usage

config = Carioca::Services::Configuration::new :config_file => 'afilename', :context => 'production'
config.config_file = 'newfile'

Parameters:

  • name (String)

    the file name



175
176
177
# File 'lib/carioca/services/configuration.rb', line 175

def config_file=(name)
  @settings.config_file = name
end

#garbageObject

Note:

close the logger

Note:

call by Carioca::Services::Registry#close

garbage service hook



183
184
185
186
# File 'lib/carioca/services/configuration.rb', line 183

def garbage
  @settings = nil
  return true
end

#save!TrueClass, FalseClass

Proxy to @settings.save!

save the Hash(self) in the file named by @config_file

Examples:

usage

config = Carioca::Services::Configuration::new :config_file => 'afilename', :context => 'production'
config.config_file = 'newfile'
config.save!

Returns:

  • (TrueClass, FalseClass)

    true if save! successfull



156
157
158
# File 'lib/carioca/services/configuration.rb', line 156

def save!
  @settings.save!
end