Module: Coinprism::Configurable

Defined in:
lib/coinprism/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.



6
7
8
# File 'lib/coinprism/configurable.rb', line 6

def access_token
  @access_token
end

#api_endpointObject



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

def api_endpoint
  File.join(@api_endpoint, "")
end

#connection_optionsObject

Returns the value of attribute connection_options.



6
7
8
# File 'lib/coinprism/configurable.rb', line 6

def connection_options
  @connection_options
end

#loginObject



58
59
60
61
62
# File 'lib/coinprism/configurable.rb', line 58

def 
  @login ||= begin
    user. if token_authenticated?
  end
end

#password=(value) ⇒ Object (writeonly)

Sets the attribute password

Parameters:

  • value

    the value to set the attribute password to.



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

def password=(value)
  @password = value
end

#per_pageObject

Returns the value of attribute per_page.



6
7
8
# File 'lib/coinprism/configurable.rb', line 6

def per_page
  @per_page
end

Class Method Details

.keysArray

List of configurable keys for Octokit::Client

Returns:

  • (Array)

    of option keys



14
15
16
17
18
19
20
21
22
# File 'lib/coinprism/configurable.rb', line 14

def keys
  @keys ||= [
    :access_token,
    :connection_options,
    :login,
    :per_page,
    :password
  ]
end

Instance Method Details

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

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



26
27
28
# File 'lib/coinprism/configurable.rb', line 26

def configure
  yield self
end

#netrc?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/coinprism/configurable.rb', line 64

def netrc?
  !!@netrc
end

#reset!Object Also known as: setup

Reset configuration options to default values



31
32
33
34
35
36
# File 'lib/coinprism/configurable.rb', line 31

def reset!
  Coinprism::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", Coinprism::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)


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

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

#web_endpointString

Base URL for generated web URLs

Returns:



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

def web_endpoint
  File.join(@web_endpoint, "")
end