Module: Particle::Configurable
Overview
Instance Attribute Summary collapse
-
#access_token ⇒ String
Particle access token for authentication.
-
#api_endpoint ⇒ Object
Clever way to add / at the end of the api_endpoint.
-
#connection_options ⇒ Hash
Configure connection options for Faraday.
-
#user_agent ⇒ String
Configure User-Agent header for requests.
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Yields an object to set up configuration options in an initializer file.
-
#reset! ⇒ Object
Reset configuration options to default values.
-
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options.
Instance Attribute Details
#access_token ⇒ String
Returns Particle access token for authentication.
17 18 19 |
# File 'lib/particle/configurable.rb', line 17 def access_token @access_token end |
#api_endpoint ⇒ Object
Clever way to add / at the end of the api_endpoint
17 18 |
# File 'lib/particle/configurable.rb', line 17 attr_accessor :access_token, :connection_options, :user_agent |
#connection_options ⇒ Hash
Returns Configure connection options for Faraday.
17 18 |
# File 'lib/particle/configurable.rb', line 17 attr_accessor :access_token, :connection_options, :user_agent |
#user_agent ⇒ String
Returns Configure User-Agent header for requests.
17 18 |
# File 'lib/particle/configurable.rb', line 17 attr_accessor :access_token, :connection_options, :user_agent |
Class Method Details
.keys ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/particle/configurable.rb', line 22 def keys @keys ||= [ :access_token, :api_endpoint, :connection_options, :user_agent ] end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Yields an object to set up configuration options in an initializer file
34 35 36 |
# File 'lib/particle/configurable.rb', line 34 def configure yield self end |
#reset! ⇒ Object
Reset configuration options to default values
39 40 41 42 43 |
# File 'lib/particle/configurable.rb', line 39 def reset! Particle::Configurable.keys.each do |key| instance_variable_set :"@#{key}", Particle::Default.[key] end end |
#same_options?(opts) ⇒ Boolean
Compares client options to a Hash of requested options
49 50 51 |
# File 'lib/particle/configurable.rb', line 49 def (opts) opts.hash == .hash end |