Module: Pixmatch::Configuration
- Included in:
- Pixmatch
- Defined in:
- lib/pixmatch/configuration.rb
Overview
Defines constants and methods related to configuration.
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a Flixated::API.
[ :username, :password, :endpoint ].freeze
- DEFAULT_USERNAME =
By default, don’t set a username.
nil.freeze
- DEFAULT_PASSWORD =
By default, don’t set a password.
nil.freeze
- DEFAULT_ENDPOINT =
The endpoint that will be used to connect if none is set.
'https://api.tineye.com'.freeze
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configuration options to default.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
26 27 28 |
# File 'lib/pixmatch/configuration.rb', line 26 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
31 32 33 |
# File 'lib/pixmatch/configuration.rb', line 31 def configure yield self end |
#options ⇒ Object
Create a hash of options and their values.
36 37 38 39 40 |
# File 'lib/pixmatch/configuration.rb', line 36 def VALID_OPTIONS_KEYS.inject({}) do |option,key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Reset all configuration options to default.
43 44 45 46 47 |
# File 'lib/pixmatch/configuration.rb', line 43 def reset self.username = DEFAULT_USERNAME self.password = DEFAULT_PASSWORD self.endpoint = DEFAULT_ENDPOINT end |