Module: Twitter::Configurable

Extended by:
Forwardable
Included in:
Twitter, Client
Defined in:
lib/twitter/configurable.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) bearer_token=(value) (writeonly)

Sets the attribute bearer_token

Parameters:

  • value

    the value to set the attribute bearer_token to.



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

def bearer_token=(value)
  @bearer_token = value
end

- (Object) connection_options

Returns the value of attribute connection_options



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

def connection_options
  @connection_options
end

- (Object) consumer_key

Returns the value of attribute consumer_key



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

def consumer_key
  @consumer_key
end

- (Object) consumer_secret=(value) (writeonly)

Sets the attribute consumer_secret

Parameters:

  • value

    the value to set the attribute consumer_secret to.



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

def consumer_secret=(value)
  @consumer_secret = value
end

- (Object) endpoint

Returns the value of attribute endpoint



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

def endpoint
  @endpoint
end

- (Object) identity_map

Returns the value of attribute identity_map



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

def identity_map
  @identity_map
end

- (Object) middleware

Returns the value of attribute middleware



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

def middleware
  @middleware
end

- (Object) oauth_token=(value) (writeonly)

Sets the attribute oauth_token

Parameters:

  • value

    the value to set the attribute oauth_token to.



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

def oauth_token=(value)
  @oauth_token = value
end

- (Object) oauth_token_secret=(value) (writeonly)

Sets the attribute oauth_token_secret

Parameters:

  • value

    the value to set the attribute oauth_token_secret to.



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

def oauth_token_secret=(value)
  @oauth_token_secret = value
end

Class Method Details

+ (Object) keys



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/twitter/configurable.rb', line 14

def keys
  @keys ||= [
    :consumer_key,
    :consumer_secret,
    :oauth_token,
    :oauth_token_secret,
    :bearer_token,
    :endpoint,
    :connection_options,
    :identity_map,
    :middleware,
  ]
end

Instance Method Details

- (Boolean) bearer_token?

Returns:

  • (Boolean)


54
55
56
# File 'lib/twitter/configurable.rb', line 54

def bearer_token?
  !!@bearer_token
end

- (Object) configure {|_self| ... }

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

Yields:

  • (_self)

Yield Parameters:

Raises:



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

def configure
  yield self
  validate_credential_type!
  self
end

- (Boolean) credentials?

Returns:

  • (Boolean)


59
60
61
# File 'lib/twitter/configurable.rb', line 59

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

- (Object) reset! Also known as: setup



40
41
42
43
44
45
# File 'lib/twitter/configurable.rb', line 40

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

- (Boolean) user_token?

Returns:

  • (Boolean)


49
50
51
# File 'lib/twitter/configurable.rb', line 49

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