Module: Nearmiss::Configurable
Instance Attribute Summary collapse
- #api_endpoint ⇒ Object
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#auto_paginate ⇒ Object
Returns the value of attribute auto_paginate.
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
-
#email ⇒ Object
writeonly
Sets the attribute email.
-
#middleware ⇒ Object
Returns the value of attribute middleware.
-
#password ⇒ Object
writeonly
Sets the attribute password.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Set configuration options using a block.
- #options ⇒ Object
-
#reset! ⇒ Object
(also: #setup)
Reset configuration options to default values.
Instance Attribute Details
#api_endpoint ⇒ Object
40 41 42 |
# File 'lib/nearmiss-ruby/configurable.rb', line 40 def api_endpoint File.join(@api_endpoint, "") end |
#api_key ⇒ Object
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/nearmiss-ruby/configurable.rb', line 4 def api_key @api_key end |
#auto_paginate ⇒ Object
Returns the value of attribute auto_paginate.
4 5 6 |
# File 'lib/nearmiss-ruby/configurable.rb', line 4 def auto_paginate @auto_paginate end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
4 5 6 |
# File 'lib/nearmiss-ruby/configurable.rb', line 4 def @connection_options end |
#email=(value) ⇒ Object (writeonly)
Sets the attribute email
5 6 7 |
# File 'lib/nearmiss-ruby/configurable.rb', line 5 def email=(value) @email = value end |
#middleware ⇒ Object
Returns the value of attribute middleware.
4 5 6 |
# File 'lib/nearmiss-ruby/configurable.rb', line 4 def middleware @middleware end |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
5 6 7 |
# File 'lib/nearmiss-ruby/configurable.rb', line 5 def password=(value) @password = value end |
#per_page ⇒ Object
Returns the value of attribute per_page.
4 5 6 |
# File 'lib/nearmiss-ruby/configurable.rb', line 4 def per_page @per_page end |
#proxy ⇒ Object
Returns the value of attribute proxy.
4 5 6 |
# File 'lib/nearmiss-ruby/configurable.rb', line 4 def proxy @proxy end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
4 5 6 |
# File 'lib/nearmiss-ruby/configurable.rb', line 4 def user_agent @user_agent end |
Class Method Details
.keys ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nearmiss-ruby/configurable.rb', line 10 def keys @keys ||= [ :middleware, :proxy, :user_agent, :connection_options, :password, :api_endpoint, :api_key, :email, :auto_paginate, :per_page ] end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Set configuration options using a block
27 28 29 |
# File 'lib/nearmiss-ruby/configurable.rb', line 27 def configure yield self end |
#options ⇒ Object
44 45 46 |
# File 'lib/nearmiss-ruby/configurable.rb', line 44 def Hash[Nearmiss::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}] end |
#reset! ⇒ Object Also known as: setup
Reset configuration options to default values
32 33 34 35 36 37 |
# File 'lib/nearmiss-ruby/configurable.rb', line 32 def reset! Nearmiss::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", Nearmiss::Default.[key]) end self end |