Module: Fantasydata::Configurable

Extended by:
Forwardable
Included in:
Fantasydata, Client
Defined in:
lib/fantasydata/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_key=(value) ⇒ Object (writeonly)

Sets the attribute api_key

Parameters:

  • value

    the value to set the attribute api_key to.



8
9
10
# File 'lib/fantasydata/configurable.rb', line 8

def api_key=(value)
  @api_key = value
end

#connection_optionsObject

Returns the value of attribute connection_options.



9
10
11
# File 'lib/fantasydata/configurable.rb', line 9

def connection_options
  @connection_options
end

#endpointObject

Returns the value of attribute endpoint.



9
10
11
# File 'lib/fantasydata/configurable.rb', line 9

def endpoint
  @endpoint
end

#middlewareObject

Returns the value of attribute middleware.



9
10
11
# File 'lib/fantasydata/configurable.rb', line 9

def middleware
  @middleware
end

Class Method Details

.keysObject



13
14
15
16
17
18
19
20
# File 'lib/fantasydata/configurable.rb', line 13

def keys
  @keys ||= [
    :api_key,
    :endpoint,
    :connection_options,
    :middleware,
  ]
end

Instance Method Details

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

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:

Raises:



27
28
29
30
31
# File 'lib/fantasydata/configurable.rb', line 27

def configure
  yield self
  validate_credential_type!
  self
end

#credentials?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fantasydata/configurable.rb', line 34

def credentials?
  credentials.values.all?
end

#reset!Object Also known as: setup



38
39
40
41
42
43
# File 'lib/fantasydata/configurable.rb', line 38

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