Class: Agcod::Configuration
- Inherits:
-
Object
- Object
- Agcod::Configuration
- Defined in:
- lib/agcod/configuration.rb
Constant Summary collapse
- REQUIRED_OPTIONS =
["access_key", "secret_key", "partner_id", "uri", "discount_percentage" ]
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .access_key ⇒ Object
- .discount_percentage ⇒ Object
- .load(app_root = nil, env = nil) ⇒ Object
- .partner_id ⇒ Object
- .secret_key ⇒ Object
- .set(opt = {}) ⇒ Object
- .uri ⇒ Object
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/agcod/configuration.rb', line 12 def logger @logger end |
.options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/agcod/configuration.rb', line 11 def @options end |
Class Method Details
.access_key ⇒ Object
45 46 47 |
# File 'lib/agcod/configuration.rb', line 45 def access_key @options["access_key"] end |
.discount_percentage ⇒ Object
61 62 63 |
# File 'lib/agcod/configuration.rb', line 61 def discount_percentage @options["discount_percentage"] end |
.load(app_root = nil, env = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/agcod/configuration.rb', line 14 def load(app_root = nil, env = nil) if app_root @app_root = app_root else @app_root = RAILS_ROOT if defined?(RAILS_ROOT) end if @app_root.nil? || !FileTest.exists?(config_filename = File.join(@app_root, 'config', 'agcod.yml')) raise Error::ConfigurationError, "Configuration for AGCOD not found" end config_file = File.read(config_filename) environment = RAILS_ENV if defined?(RAILS_ENV) environment = env if env @options = YAML.load(config_file)[environment] @options end |
.partner_id ⇒ Object
53 54 55 |
# File 'lib/agcod/configuration.rb', line 53 def partner_id @options["partner_id"] end |
.secret_key ⇒ Object
49 50 51 |
# File 'lib/agcod/configuration.rb', line 49 def secret_key @options["secret_key"] end |
.set(opt = {}) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/agcod/configuration.rb', line 37 def set(opt = {}) @options ||= {} @options.merge!(opt) @options end |
.uri ⇒ Object
57 58 59 |
# File 'lib/agcod/configuration.rb', line 57 def uri @options["uri"] end |