Module: Cryptoprocessing::Configurable

Included in:
Cryptoprocessing, Client
Defined in:
lib/cryptoprocessing/configurable.rb

Overview

Configuration options for Client, defaulting to values in Default

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#api_endpointString

Returns Base URL for API requests.

Returns:

  • (String)

    Base URL for API requests.



11
# File 'lib/cryptoprocessing/configurable.rb', line 11

attr_writer :email, :password, :api_endpoint, :api_namespace

#api_namespaceObject



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

def api_namespace
  File.join(@api_namespace, '')
end

#blockchain_typeObject

Returns the value of attribute blockchain_type.



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

def blockchain_type
  @blockchain_type
end

#email=(value) ⇒ Object (writeonly)

Sets the attribute email

Parameters:

  • value

    the value to set the attribute email to.



11
12
13
# File 'lib/cryptoprocessing/configurable.rb', line 11

def email=(value)
  @email = value
end

#password=(value) ⇒ Object (writeonly)

Sets the attribute password

Parameters:

  • value

    the value to set the attribute password to.



11
12
13
# File 'lib/cryptoprocessing/configurable.rb', line 11

def password=(value)
  @password = value
end

#user_agentObject

Returns the value of attribute user_agent.



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

def user_agent
  @user_agent
end

Class Method Details

.keysArray

List of configurable keys for Cryptoprocessing::Client

Returns:

  • (Array)

    of option keys



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

def keys
  @keys ||= [
      :access_token,
      :api_endpoint,
      :api_namespace,
      :blockchain_type,
      :email,
      :password,
      :user_agent
  ]
end

Instance Method Details

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

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



30
31
32
# File 'lib/cryptoprocessing/configurable.rb', line 30

def configure
  yield self
end

#netrc?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/cryptoprocessing/configurable.rb', line 63

def netrc?
  !!@netrc
end

#reset!Object Also known as: setup

Reset configuration options to default values



35
36
37
38
39
40
# File 'lib/cryptoprocessing/configurable.rb', line 35

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

#same_options?(opts) ⇒ Boolean

Compares client options to a Hash of requested options

Parameters:

  • opts (Hash)

    Options to compare with current client options

Returns:

  • (Boolean)


47
48
49
# File 'lib/cryptoprocessing/configurable.rb', line 47

def same_options?(opts)
  opts.hash == options.hash
end