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.
12 13 14 |
# File 'lib/vero/config.rb', line 12 def initialize self.reset! end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/vero/config.rb', line 6 def api_key @api_key end |
#async ⇒ Object
Returns the value of attribute async.
6 7 8 |
# File 'lib/vero/config.rb', line 6 def async @async end |
#development_mode ⇒ Object
Returns the value of attribute development_mode.
6 7 8 |
# File 'lib/vero/config.rb', line 6 def development_mode @development_mode end |
#disabled ⇒ Object
Returns the value of attribute disabled.
6 7 8 |
# File 'lib/vero/config.rb', line 6 def disabled @disabled end |
#domain ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/vero/config.rb', line 27 def domain if @domain.blank? 'https://api.getvero.com' else @domain =~ /http[s]?\:\/\/.+/ ? @domain : "http://#{@domain}" end end |
#logging ⇒ Object
Returns the value of attribute logging.
6 7 8 |
# File 'lib/vero/config.rb', line 6 def logging @logging end |
#secret ⇒ Object
Returns the value of attribute secret.
6 7 8 |
# File 'lib/vero/config.rb', line 6 def secret @secret end |
Class Method Details
.available_attributes ⇒ Object
8 9 10 |
# File 'lib/vero/config.rb', line 8 def self.available_attributes [:api_key, :secret, :development_mode, :async, :disabled, :logging, :domain] end |
Instance Method Details
#auth_token ⇒ Object
35 36 37 38 |
# File 'lib/vero/config.rb', line 35 def auth_token return unless auth_token? ::Base64::encode64("#{api_key}:#{secret}").gsub(/[\n ]/, '') end |
#auth_token? ⇒ Boolean
40 41 42 |
# File 'lib/vero/config.rb', line 40 def auth_token? !api_key.blank? && !secret.blank? end |
#config_params ⇒ Object
16 17 18 |
# File 'lib/vero/config.rb', line 16 def config_params = {:api_key => self.api_key, :secret => self.secret} end |
#configured? ⇒ Boolean
44 45 46 |
# File 'lib/vero/config.rb', line 44 def configured? auth_token? end |
#disable_requests! ⇒ Object
48 49 50 |
# File 'lib/vero/config.rb', line 48 def disable_requests! self.disabled = true end |
#request_params ⇒ Object
20 21 22 23 24 25 |
# File 'lib/vero/config.rb', line 20 def request_params { :auth_token => self.auth_token, :development_mode => self.development_mode }.reject { |_, v| v.nil? } end |
#reset! ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/vero/config.rb', line 52 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
61 62 63 64 65 66 67 68 |
# File 'lib/vero/config.rb', line 61 def update_attributes(attributes = {}) return unless attributes.is_a?(Hash) Vero::Config.available_attributes.each do |symbol| method_name = "#{symbol}=".to_sym self.send(method_name, attributes[symbol]) if self.respond_to?(method_name) && attributes.has_key?(symbol) end end |