Module: Fortnox::Configurable

Included in:
Fortnox, Client
Defined in:
lib/fortnox/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



4
5
6
# File 'lib/fortnox/configurable.rb', line 4

def access_token
  @access_token
end

#authorization_codeObject

Returns the value of attribute authorization_code.



4
5
6
# File 'lib/fortnox/configurable.rb', line 4

def authorization_code
  @authorization_code
end

#client_idObject

Returns the value of attribute client_id.



4
5
6
# File 'lib/fortnox/configurable.rb', line 4

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



4
5
6
# File 'lib/fortnox/configurable.rb', line 4

def client_secret
  @client_secret
end

Class Method Details

.keysObject



7
8
9
10
11
12
13
14
# File 'lib/fortnox/configurable.rb', line 7

def keys
  @keys ||= [
    :client_id,
    :access_token,
    :client_secret,
    :authorization_code
  ]
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



17
18
19
# File 'lib/fortnox/configurable.rb', line 17

def configure
  yield self
end

#optionsObject



28
29
30
# File 'lib/fortnox/configurable.rb', line 28

def options
  Hash[Fortnox::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}]
end

#reset!Object Also known as: setup



21
22
23
24
25
# File 'lib/fortnox/configurable.rb', line 21

def reset!
  Fortnox::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", Fortnox::Default.options[key])
  end
end