Class: Newebpay::Config

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/newebpay/config.rb

Overview

Config of Newebpay

Since:

  • 0.1.0

Constant Summary collapse

LOCK =

Since:

  • 0.1.0

Mutex.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, &block) ⇒ Config

Initialize

Since:

  • 0.2.0



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_ivObject

Since:

  • 0.1.0



47
48
49
# File 'lib/newebpay/config.rb', line 47

def hash_iv
  @hash_iv
end

#hash_keyObject

Since:

  • 0.1.0



47
48
49
# File 'lib/newebpay/config.rb', line 47

def hash_key
  @hash_key
end

Class Method Details

.currentObject

Current activate config

Since:

  • 0.1.0



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

Since:

  • 0.2.0



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

Since:

  • 0.1.0



63
64
65
# File 'lib/newebpay/config.rb', line 63

def config(&block)
  instance_exec(self, &block)
end