Class: CloudPayments::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_payments/config.rb

Constant Summary collapse

DEFAULT_LOGGER =
->{
  require 'logger'
  logger = Logger.new(STDERR)
  logger.progname = 'cloud_payments'
  logger.formatter = ->(severity, datetime, progname, msg){ "#{datetime} (#{progname}): #{msg}\n" }
  logger
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



15
16
17
18
19
20
21
22
23
24
# File 'lib/cloud_payments/config.rb', line 15

def initialize
  @log = false
  @serializer = Client::Serializer::MultiJson.new(self)
  @connection_options = {}
  @connection_block = nil
  @host = 'https://api.cloudpayments.ru'
  if block_given?
    yield self
  end
end

Instance Attribute Details

#connection_optionsObject

Returns the value of attribute connection_options.



4
5
6
# File 'lib/cloud_payments/config.rb', line 4

def connection_options
  @connection_options
end

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/cloud_payments/config.rb', line 4

def host
  @host
end

#logObject

Returns the value of attribute log.



4
5
6
# File 'lib/cloud_payments/config.rb', line 4

def log
  @log
end

#loggerObject



26
27
28
# File 'lib/cloud_payments/config.rb', line 26

def logger
  @logger ||= log ? DEFAULT_LOGGER.call : nil
end

#public_keyObject

Returns the value of attribute public_key.



4
5
6
# File 'lib/cloud_payments/config.rb', line 4

def public_key
  @public_key
end

#raise_banking_errorsObject

Returns the value of attribute raise_banking_errors.



4
5
6
# File 'lib/cloud_payments/config.rb', line 4

def raise_banking_errors
  @raise_banking_errors
end

#secret_keyObject

Returns the value of attribute secret_key.



4
5
6
# File 'lib/cloud_payments/config.rb', line 4

def secret_key
  @secret_key
end

#serializerObject

Returns the value of attribute serializer.



4
5
6
# File 'lib/cloud_payments/config.rb', line 4

def serializer
  @serializer
end

Instance Method Details

#available_currenciesObject



30
31
32
# File 'lib/cloud_payments/config.rb', line 30

def available_currencies
  %w{RUB USD EUR}
end

#connection_block(&block) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/cloud_payments/config.rb', line 34

def connection_block(&block)
  if block_given?
    @connection_block = block
  else
    @connection_block
  end
end

#dupObject



42
43
44
45
46
# File 'lib/cloud_payments/config.rb', line 42

def dup
  clone = super
  clone.connection_options = connection_options.dup
  clone
end