Module: Coinprism::Configurable
- Defined in:
- lib/coinprism/configurable.rb
Overview
Configuration options for Client, defaulting to values in Default
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
- #api_endpoint ⇒ Object
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
- #login ⇒ Object
-
#password ⇒ Object
writeonly
Sets the attribute password.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
Class Method Summary collapse
-
.keys ⇒ Array
List of configurable keys for Octokit::Client.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Set configuration options using a block.
- #netrc? ⇒ Boolean
-
#reset! ⇒ Object
(also: #setup)
Reset configuration options to default values.
-
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options.
-
#web_endpoint ⇒ String
Base URL for generated web URLs.
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/coinprism/configurable.rb', line 6 def access_token @access_token end |
#api_endpoint ⇒ Object
47 48 49 |
# File 'lib/coinprism/configurable.rb', line 47 def api_endpoint File.join(@api_endpoint, "") end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
6 7 8 |
# File 'lib/coinprism/configurable.rb', line 6 def @connection_options end |
#login ⇒ Object
58 59 60 61 62 |
# File 'lib/coinprism/configurable.rb', line 58 def login @login ||= begin user.login if token_authenticated? end end |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
8 9 10 |
# File 'lib/coinprism/configurable.rb', line 8 def password=(value) @password = value end |
#per_page ⇒ Object
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
.keys ⇒ Array
List of configurable keys for Octokit::Client
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
26 27 28 |
# File 'lib/coinprism/configurable.rb', line 26 def configure yield self end |
#netrc? ⇒ 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.[key]) end self end |
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options
43 44 45 |
# File 'lib/coinprism/configurable.rb', line 43 def (opts) opts.hash == .hash end |
#web_endpoint ⇒ String
Base URL for generated web URLs
54 55 56 |
# File 'lib/coinprism/configurable.rb', line 54 def web_endpoint File.join(@web_endpoint, "") end |