Module: Croudia::Configurable

Included in:
Croudia, Client
Defined in:
lib/croudia/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_token=(value) ⇒ Object (writeonly)

Sets the attribute access_token

Parameters:

  • value

    the value to set the attribute access_token to.



5
6
7
# File 'lib/croudia/configurable.rb', line 5

def access_token=(value)
  @access_token = value
end

#client_idObject

Returns the value of attribute client_id.



6
7
8
# File 'lib/croudia/configurable.rb', line 6

def client_id
  @client_id
end

#client_secret=(value) ⇒ Object (writeonly)

Sets the attribute client_secret

Parameters:

  • value

    the value to set the attribute client_secret to.



5
6
7
# File 'lib/croudia/configurable.rb', line 5

def client_secret=(value)
  @client_secret = value
end

#connection_optionsObject

Returns the value of attribute connection_options.



6
7
8
# File 'lib/croudia/configurable.rb', line 6

def connection_options
  @connection_options
end

#endpointObject

Returns the value of attribute endpoint.



6
7
8
# File 'lib/croudia/configurable.rb', line 6

def endpoint
  @endpoint
end

#middlewareObject

Returns the value of attribute middleware.



6
7
8
# File 'lib/croudia/configurable.rb', line 6

def middleware
  @middleware
end

Class Method Details

.keysObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/croudia/configurable.rb', line 9

def keys
  @keys ||= [
    :endpoint,
    :connection_options,
    :middleware,
    :client_id,
    :client_secret,
    :access_token,
  ]
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
  self
end

#optionsObject



33
34
35
36
37
# File 'lib/croudia/configurable.rb', line 33

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

#reset!Object Also known as: setup



26
27
28
29
30
# File 'lib/croudia/configurable.rb', line 26

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