Class: Cardflex::Configuration
- Inherits:
-
Object
- Object
- Cardflex::Configuration
- Defined in:
- lib/cardflex/configuration.rb
Constant Summary collapse
- API_VERSION =
3- SERVER =
"secure.cardflexonline.com"- PORT =
443
Class Attribute Summary collapse
-
.api_key ⇒ Object
writeonly
Sets the attribute api_key.
- .logger ⇒ Object
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Class Method Summary collapse
- ._default_logger ⇒ Object
- .environment=(env) ⇒ Object
- .expectant_reader(*attributes) ⇒ Object
- .gateway ⇒ Object
- .instantiate ⇒ Object
Instance Method Summary collapse
- #api_version ⇒ Object
- #ca_file ⇒ Object
- #http ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #logger ⇒ Object
- #port ⇒ Object
- #protocol ⇒ Object
- #server ⇒ Object
- #ssl? ⇒ Boolean
- #three_step_path ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 |
# File 'lib/cardflex/configuration.rb', line 24 def initialize(={}) [:environment, :api_key, :logger].each do |attr| instance_variable_set("@#{attr}", [attr]) end end |
Class Attribute Details
.api_key=(value) ⇒ Object (writeonly)
Sets the attribute api_key
8 9 10 |
# File 'lib/cardflex/configuration.rb', line 8 def api_key=(value) @api_key = value end |
.logger ⇒ Object
86 87 88 |
# File 'lib/cardflex/configuration.rb', line 86 def self.logger @logger ||= _default_logger end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/cardflex/configuration.rb', line 11 def api_key @api_key end |
Class Method Details
._default_logger ⇒ Object
90 91 92 93 94 |
# File 'lib/cardflex/configuration.rb', line 90 def self._default_logger logger = Logger.new(STDOUT) logger.level = Logger::INFO logger end |
.environment=(env) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/cardflex/configuration.rb', line 30 def self.environment=(env) unless [:development, :test, :production].include?(env) raise ArgumentError, "#{env} is not a valid environment" end @environment = env end |
.expectant_reader(*attributes) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/cardflex/configuration.rb', line 13 def self.expectant_reader(*attributes) attributes.each do |attribute| (class << self; self; end).send(:define_method, attribute) do value = instance_variable_get("@#{attribute}") raise ConfigurationError.new(attribute.to_s, "needs to be set") unless value value end end end |
.gateway ⇒ Object
38 39 40 |
# File 'lib/cardflex/configuration.rb', line 38 def self.gateway Cardflex::Gateway.new(instantiate) end |
.instantiate ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/cardflex/configuration.rb', line 42 def self.instantiate config = new( :environment => @environment, :logger => logger, :api_key => api_key ) end |
Instance Method Details
#api_version ⇒ Object
78 79 80 |
# File 'lib/cardflex/configuration.rb', line 78 def api_version API_VERSION end |
#ca_file ⇒ Object
50 51 52 |
# File 'lib/cardflex/configuration.rb', line 50 def ca_file File.(File.join(File.dirname(__FILE__), "..", "ssl", "ca-certificates.ca.crt")) end |
#logger ⇒ Object
82 83 84 |
# File 'lib/cardflex/configuration.rb', line 82 def logger @logger ||= self.class._default_logger end |
#port ⇒ Object
70 71 72 |
# File 'lib/cardflex/configuration.rb', line 70 def port PORT end |
#protocol ⇒ Object
66 67 68 |
# File 'lib/cardflex/configuration.rb', line 66 def protocol "https" end |
#server ⇒ Object
62 63 64 |
# File 'lib/cardflex/configuration.rb', line 62 def server SERVER end |
#ssl? ⇒ Boolean
74 75 76 |
# File 'lib/cardflex/configuration.rb', line 74 def ssl? true end |
#three_step_path ⇒ Object
58 59 60 |
# File 'lib/cardflex/configuration.rb', line 58 def three_step_path "/api/v2/three-step" end |