Class: Newebpay::Config
- Inherits:
-
Object
- Object
- Newebpay::Config
- Extended by:
- Forwardable
- Defined in:
- lib/newebpay/config.rb
Overview
Config of Newebpay
Constant Summary collapse
- LOCK =
Mutex.new
Instance Attribute Summary collapse
Class Method Summary collapse
-
.current ⇒ Object
Current activate config.
-
.switch(config, &_block) ⇒ Object
Temporary switch to another config.
Instance Method Summary collapse
-
#config(&block) ⇒ Object
Update current config.
-
#initialize(attributes = {}, &block) ⇒ Config
constructor
Initialize.
Constructor Details
#initialize(attributes = {}, &block) ⇒ Config
Initialize
52 53 54 55 56 57 58 |
# File 'lib/newebpay/config.rb', line 52 def initialize(attributes = {}, &block) attributes.each do |name, value| send("#{name}=", value) if respond_to?("#{name}=") end config(&block) if defined?(yield) end |
Instance Attribute Details
#hash_iv ⇒ Object
47 48 49 |
# File 'lib/newebpay/config.rb', line 47 def hash_iv @hash_iv end |
#hash_key ⇒ Object
47 48 49 |
# File 'lib/newebpay/config.rb', line 47 def hash_key @hash_key end |
Class Method Details
.current ⇒ Object
Current activate config
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/newebpay/config.rb', line 19 def current return @current if @current LOCK.synchronize do return @current if @current @current ||= new end @current end |
.switch(config, &_block) ⇒ Object
Temporary switch to another config
34 35 36 37 38 39 40 41 |
# File 'lib/newebpay/config.rb', line 34 def switch(config, &_block) LOCK.synchronize do temp = @current @current = config yield @current if defined?(yield) @current = temp end end |
Instance Method Details
#config(&block) ⇒ Object
Update current config
63 64 65 |
# File 'lib/newebpay/config.rb', line 63 def config(&block) instance_exec(self, &block) end |