Module: FreshService::Configurable
- Included in:
- FreshService, Client
- Defined in:
- lib/fresh_service/configurable.rb
Overview
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#env ⇒ Object
Returns the value of attribute env.
-
#organisation ⇒ Object
Returns the value of attribute organisation.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
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
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
7 8 9 |
# File 'lib/fresh_service/configurable.rb', line 7 def api_endpoint @api_endpoint end |
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/fresh_service/configurable.rb', line 7 def api_key @api_key end |
#content_type ⇒ Object
Returns the value of attribute content_type.
7 8 9 |
# File 'lib/fresh_service/configurable.rb', line 7 def content_type @content_type end |
#env ⇒ Object
Returns the value of attribute env.
7 8 9 |
# File 'lib/fresh_service/configurable.rb', line 7 def env @env end |
#organisation ⇒ Object
Returns the value of attribute organisation.
7 8 9 |
# File 'lib/fresh_service/configurable.rb', line 7 def organisation @organisation end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
7 8 9 |
# File 'lib/fresh_service/configurable.rb', line 7 def user_agent @user_agent end |
Class Method Details
.keys ⇒ Array
List of configurable keys for FreshService::Client
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fresh_service/configurable.rb', line 13 def keys @keys ||= i[ organisation env api_key content_type api_endpoint user_agent ] end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Set configuration options using a block
26 27 28 |
# File 'lib/fresh_service/configurable.rb', line 26 def configure yield self end |
#reset! ⇒ Object Also known as: setup
Reset configuration options to default values
31 32 33 34 35 36 |
# File 'lib/fresh_service/configurable.rb', line 31 def reset! FreshService::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", FreshService::Default.[key]) end self end |
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options
43 44 45 |
# File 'lib/fresh_service/configurable.rb', line 43 def (opts) opts.hash == .hash end |