Class: Barion::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/barion/config.rb

Overview

Encloses all Barion related configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#acronymObject



18
19
20
# File 'lib/barion/config.rb', line 18

def acronym
  @acronym || ''
end

#default_payeeObject

Returns the value of attribute default_payee.



10
11
12
# File 'lib/barion/config.rb', line 10

def default_payee
  @default_payee
end

#pixel_idObject

Returns the value of attribute pixel_id.



12
13
14
# File 'lib/barion/config.rb', line 12

def pixel_id
  @pixel_id
end

#publickeyObject

Returns the value of attribute publickey.



10
11
12
# File 'lib/barion/config.rb', line 10

def publickey
  @publickey
end

Instance Method Details

#endpointObject



58
59
60
61
# File 'lib/barion/config.rb', line 58

def endpoint
  env = sandbox? ? :test : :prod
  rest_client_class.new ::Barion::BASE_URL[env]
end

#item_classObject



86
87
88
89
90
91
# File 'lib/barion/config.rb', line 86

def item_class
  # This is nil before the initializer is installed.
  return nil if @_item_class.nil?

  @_item_class.constantize
end

#item_class=(class_name) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/barion/config.rb', line 78

def item_class=(class_name)
  unless class_name.is_a?(String)
    raise ArgumentError, "::Barion.config.item_class must be set to a ::String, got #{class_name.inspect}"
  end

  @_item_class = class_name
end

#poskeyObject



14
15
16
# File 'lib/barion/config.rb', line 14

def poskey
  @_poskey || nil
end

#poskey=(key) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/barion/config.rb', line 22

def poskey=(key)
  unless key.is_a?(String)
    raise ArgumentError,
          "::Barion::Config.poskey must be set to a ::String, got #{key.inspect}"
  end

  @_poskey = key
end

#rest_client_classObject



93
94
95
# File 'lib/barion/config.rb', line 93

def rest_client_class
  (@_rest_client_class || '::RestClient::Resource').constantize
end

#rest_client_class=(class_name) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/barion/config.rb', line 97

def rest_client_class=(class_name)
  unless class_name.is_a?(String)
    raise ArgumentError, "::Barion::Config.rest_client_class must be set to a ::String, got #{class_name.inspect}"
  end

  @_rest_client_class = class_name
end

#sandboxObject



31
32
33
# File 'lib/barion/config.rb', line 31

def sandbox
  sandbox?
end

#sandbox=(val) ⇒ Object



40
41
42
# File 'lib/barion/config.rb', line 40

def sandbox=(val)
  @_sandbox = !!val
end

#sandbox?Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/barion/config.rb', line 35

def sandbox?
  @_sandbox = true if @_sandbox.nil?
  @_sandbox
end

#user_classObject



71
72
73
74
75
76
# File 'lib/barion/config.rb', line 71

def user_class
  # This is nil before the initializer is installed.
  return nil if @_user_class.nil?

  @_user_class.constantize
end

#user_class=(class_name) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/barion/config.rb', line 63

def user_class=(class_name)
  unless class_name.is_a?(String)
    raise ArgumentError, "::Barion:.config.user_class must be set to a ::String, got #{class_name.inspect}"
  end

  @_user_class = class_name
end