Class: OmiseGO::Configuration
- Inherits:
-
Object
- Object
- OmiseGO::Configuration
- Defined in:
- lib/omisego/configuration.rb
Constant Summary collapse
- OPTIONS =
{ access_key: -> { ENV['OMISEGO_ACCESS_KEY'] }, secret_key: -> { ENV['OMISEGO_SECRET_KEY'] }, base_url: -> { ENV['OMISEGO_BASE_URL'] }, logger: nil }.freeze
- OMISEGO_OPTIONS =
{ api_version: '1', auth_scheme: 'OMGProvider', api_prefix: '/api/admin', models: { user: OmiseGO::User, error: OmiseGO::Error, authentication_token: OmiseGO::AuthenticationToken, wallet: OmiseGO::Wallet, balance: OmiseGO::Wallet, token: OmiseGO::Token, list: OmiseGO::List, setting: OmiseGO::Setting, transaction: OmiseGO::Transaction, exchange: OmiseGO::Exchange, transaction_source: OmiseGO::TransactionSource } }.freeze
Instance Method Summary collapse
- #[](option) ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(options) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/omisego/configuration.rb', line 32 def initialize( = {}) OPTIONS.each do |name, val| value = ? [name] || [name.to_sym] : nil value ||= val.call if val.respond_to?(:call) instance_variable_set("@#{name}", value) end OMISEGO_OPTIONS.each do |name, value| instance_variable_set("@#{name}", value) end end |
Instance Method Details
#[](option) ⇒ Object
44 45 46 |
# File 'lib/omisego/configuration.rb', line 44 def [](option) instance_variable_get("@#{option}") end |
#merge(options) ⇒ Object
54 55 56 57 58 |
# File 'lib/omisego/configuration.rb', line 54 def merge() OPTIONS.each_key do |name| instance_variable_set("@#{name}", [name]) if [name] end end |
#to_hash ⇒ Object
48 49 50 51 52 |
# File 'lib/omisego/configuration.rb', line 48 def to_hash OPTIONS.keys.each_with_object({}) do |option, hash| hash[option.to_sym] = self[option] end end |