Module: Hackeroo::Configurable

Extended by:
Forwardable
Included in:
Hackeroo, Client
Defined in:
lib/hackeroo/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientkeyObject

Returns the value of attribute clientkey.



7
8
9
# File 'lib/hackeroo/configurable.rb', line 7

def clientkey
  @clientkey
end

#connection_optionsObject

Returns the value of attribute connection_options.



7
8
9
# File 'lib/hackeroo/configurable.rb', line 7

def connection_options
  @connection_options
end

#endpointObject

Returns the value of attribute endpoint.



7
8
9
# File 'lib/hackeroo/configurable.rb', line 7

def endpoint
  @endpoint
end

#identity_mapObject

Returns the value of attribute identity_map.



7
8
9
# File 'lib/hackeroo/configurable.rb', line 7

def identity_map
  @identity_map
end

#middlewareObject

Returns the value of attribute middleware.



7
8
9
# File 'lib/hackeroo/configurable.rb', line 7

def middleware
  @middleware
end

Class Method Details

.keysObject



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

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

Instance Method Details

#bearer_token?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/hackeroo/configurable.rb', line 48

def bearer_token?
  !!@bearer_token
end

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

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

Yields:

  • (_self)

Yield Parameters:

Raises:



28
29
30
31
32
# File 'lib/hackeroo/configurable.rb', line 28

def configure
  yield self
  validate_credential_type!
  self
end

#credentials?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/hackeroo/configurable.rb', line 53

def credentials?
  credentials.values.all? || bearer_token?
end

#reset!Object Also known as: setup



34
35
36
37
38
39
# File 'lib/hackeroo/configurable.rb', line 34

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

#user_token?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/hackeroo/configurable.rb', line 43

def user_token?
  !!(@oauth_token && @oauth_token_secret)
end