Module: Reuters::Credentials

Defined in:
lib/reuters/credentials.rb

Overview

The Credentials module handles storing the configured credentials for the Reuters gem.

Examples:

Configuring credentials.

Reuters.configure do |config|
  config.credentials do ||
    # Set username
    .username = "my_username"
    # Set my password
    .password = "my_super_secret_password"
    # Set application ID
    .application_id = "application_id"
  end
end

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.app_idString, Nil

The application ID to use for all requests to the Reuter’s API.

Returns:

  • (String, Nil)

    The configured appication ID, or nil if none is set.



40
# File 'lib/reuters/credentials.rb', line 40

mattr_accessor :username

.passwordString, Nil

The password to use to authenticate against the Reuter’s API with.

Returns:

  • (String, Nil)

    The configured password, or nil if none is set.



# File 'lib/reuters/credentials.rb', line 26

.usernameString, Nil

The username to use to authenticate against the Reuter’s API with.

Returns:

  • (String, Nil)

    The configured username, or nil if none is set.



# File 'lib/reuters/credentials.rb', line 19

Class Method Details

.configure {|config| ... } ⇒ Object

Enables credentials to be configured by passing in itself as a block which enables static variables to be set.

Yields:

  • (config)

    The credentials to be configured.



73
74
75
# File 'lib/reuters/credentials.rb', line 73

def self.configure
  yield self
end

.details {|username, password, app_id| ... } ⇒ Object

Yields the configured credentials to connect to the Reuter’s API with.

Yields:

Yield Parameters:

  • username (String, Nil)

    configured, or nil if one is not set.

  • password (String, Nil)

    configured, or nil if one is not set.

  • app_id (String, Nil)

    configured, or nil if one is not set.



57
58
59
# File 'lib/reuters/credentials.rb', line 57

def self.details
  yield @@username, @@password, @@app_id
end

.to_hHash

Returns credentials that have been configured as a Hash.

Returns:

  • (Hash)

    the credentials that have been configured.



64
65
66
# File 'lib/reuters/credentials.rb', line 64

def self.to_h
  { username: username, password: password, app_id: app_id }
end