Module: Karatekit::Configurable
Overview
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#api_endpoint ⇒ String
Base URL for API requests.
-
#auto_paginate ⇒ Boolean
Auto fetch next page of results until rate limit reached.
-
#connection_options ⇒ Hash
Configure connection options for Faraday.
-
#default_media_type ⇒ Object
Returns the value of attribute default_media_type.
-
#middleware ⇒ Faraday::Builder or Faraday::RackBuilder
Configure middleware for Faraday.
-
#per_page ⇒ String
Configure page size for paginated results.
-
#user_agent ⇒ String
Configure User-Agent header for requests.
Class Method Summary collapse
-
.keys ⇒ Array
List of configurable keys for Client.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Set configuration options using a block.
-
#reset! ⇒ Object
(also: #setup)
Reset configuration options to default values.
-
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options.
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
24 25 26 |
# File 'lib/karatekit/configurable.rb', line 24 def access_token @access_token end |
#api_endpoint ⇒ String
Returns Base URL for API requests. default: api.github.com/.
24 25 26 27 |
# File 'lib/karatekit/configurable.rb', line 24 attr_accessor :access_token, :auto_paginate, :connection_options, :default_media_type, :middleware, :per_page, :user_agent |
#auto_paginate ⇒ Boolean
Returns Auto fetch next page of results until rate limit reached.
24 25 26 27 |
# File 'lib/karatekit/configurable.rb', line 24 attr_accessor :access_token, :auto_paginate, :connection_options, :default_media_type, :middleware, :per_page, :user_agent |
#connection_options ⇒ Hash
Returns Configure connection options for Faraday.
24 25 26 27 |
# File 'lib/karatekit/configurable.rb', line 24 attr_accessor :access_token, :auto_paginate, :connection_options, :default_media_type, :middleware, :per_page, :user_agent |
#default_media_type ⇒ Object
Returns the value of attribute default_media_type.
24 25 26 |
# File 'lib/karatekit/configurable.rb', line 24 def default_media_type @default_media_type end |
#middleware ⇒ Faraday::Builder or Faraday::RackBuilder
Returns Configure middleware for Faraday.
24 25 26 27 |
# File 'lib/karatekit/configurable.rb', line 24 attr_accessor :access_token, :auto_paginate, :connection_options, :default_media_type, :middleware, :per_page, :user_agent |
#per_page ⇒ String
Returns Configure page size for paginated results. API default: 30.
24 25 26 27 |
# File 'lib/karatekit/configurable.rb', line 24 attr_accessor :access_token, :auto_paginate, :connection_options, :default_media_type, :middleware, :per_page, :user_agent |
#user_agent ⇒ String
Returns Configure User-Agent header for requests.
24 25 26 27 |
# File 'lib/karatekit/configurable.rb', line 24 attr_accessor :access_token, :auto_paginate, :connection_options, :default_media_type, :middleware, :per_page, :user_agent |
Class Method Details
.keys ⇒ Array
List of configurable keys for Karatekit::Client
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/karatekit/configurable.rb', line 34 def keys @keys ||= [ :access_token, :api_endpoint, :default_media_type, :auto_paginate, :connection_options, :middleware, :per_page, :user_agent, ] end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Set configuration options using a block
49 50 51 |
# File 'lib/karatekit/configurable.rb', line 49 def configure yield self end |
#reset! ⇒ Object Also known as: setup
Reset configuration options to default values
54 55 56 57 58 59 |
# File 'lib/karatekit/configurable.rb', line 54 def reset! Karatekit::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", Karatekit::Default.[key]) end self end |
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options
66 67 68 |
# File 'lib/karatekit/configurable.rb', line 66 def (opts) opts.hash == .hash end |