Class: Vero::Config
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#async ⇒ Object
Returns the value of attribute async.
-
#development_mode ⇒ Object
Returns the value of attribute development_mode.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
- #domain ⇒ Object
-
#logging ⇒ Object
Returns the value of attribute logging.
-
#secret ⇒ Object
Returns the value of attribute secret.
Class Method Summary collapse
Instance Method Summary collapse
- #auth_token ⇒ Object
- #auth_token? ⇒ Boolean
- #config_params ⇒ Object
- #configured? ⇒ Boolean
- #disable_requests! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #request_params ⇒ Object
- #reset! ⇒ Object
- #update_attributes(attributes = {}) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
14 15 16 |
# File 'lib/vero/config.rb', line 14 def initialize reset! end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/vero/config.rb', line 8 def api_key @api_key end |
#async ⇒ Object
Returns the value of attribute async.
8 9 10 |
# File 'lib/vero/config.rb', line 8 def async @async end |
#development_mode ⇒ Object
Returns the value of attribute development_mode.
8 9 10 |
# File 'lib/vero/config.rb', line 8 def development_mode @development_mode end |
#disabled ⇒ Object
Returns the value of attribute disabled.
8 9 10 |
# File 'lib/vero/config.rb', line 8 def disabled @disabled end |
#domain ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/vero/config.rb', line 29 def domain if @domain.blank? 'https://api.getvero.com' else @domain =~ %r{https?://.+} ? @domain : "http://#{@domain}" end end |
#logging ⇒ Object
Returns the value of attribute logging.
8 9 10 |
# File 'lib/vero/config.rb', line 8 def logging @logging end |
#secret ⇒ Object
Returns the value of attribute secret.
8 9 10 |
# File 'lib/vero/config.rb', line 8 def secret @secret end |
Class Method Details
.available_attributes ⇒ Object
10 11 12 |
# File 'lib/vero/config.rb', line 10 def self.available_attributes i[api_key secret development_mode async disabled logging domain] end |
Instance Method Details
#auth_token ⇒ Object
37 38 39 40 41 |
# File 'lib/vero/config.rb', line 37 def auth_token return unless auth_token? ::Base64.encode64("#{api_key}:#{secret}").gsub(/[\n ]/, '') end |
#auth_token? ⇒ Boolean
43 44 45 |
# File 'lib/vero/config.rb', line 43 def auth_token? !api_key.blank? && !secret.blank? end |
#config_params ⇒ Object
18 19 20 |
# File 'lib/vero/config.rb', line 18 def config_params { api_key: api_key, secret: secret } end |
#configured? ⇒ Boolean
47 48 49 |
# File 'lib/vero/config.rb', line 47 def configured? auth_token? end |
#disable_requests! ⇒ Object
51 52 53 |
# File 'lib/vero/config.rb', line 51 def disable_requests! self.disabled = true end |
#request_params ⇒ Object
22 23 24 25 26 27 |
# File 'lib/vero/config.rb', line 22 def request_params { auth_token: auth_token, development_mode: development_mode }.reject { |_, v| v.nil? } end |
#reset! ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/vero/config.rb', line 55 def reset! self.disabled = false self.development_mode = false self.async = true self.logging = false self.api_key = nil self.secret = nil end |
#update_attributes(attributes = {}) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/vero/config.rb', line 64 def update_attributes(attributes = {}) return unless attributes.is_a?(Hash) Vero::Config.available_attributes.each do |symbol| method_name = "#{symbol}=".to_sym send(method_name, attributes[symbol]) if respond_to?(method_name) && attributes.key?(symbol) end end |