class Newebpay::Config

Config of Newebpay

@since 0.1.0

Constants

LOCK

@since 0.1.0

Attributes

hash_iv[RW]

@since 0.1.0

hash_key[RW]

@since 0.1.0

Public Class Methods

current() click to toggle source

Current activate config

@since 0.1.0

# 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
new(attributes = {}) { || ... } click to toggle source

Initialize

@since 0.2.0

# 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
switch(config) { |current| ... } click to toggle source

Temporary switch to another config

@since 0.2.0

# 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

Public Instance Methods

config(&block) click to toggle source

Update current config

@since 0.1.0

# File lib/newebpay/config.rb, line 63
def config(&block)
  instance_exec(self, &block)
end