Module: Nearmiss::Configurable

Included in:
Nearmiss, Client
Defined in:
lib/nearmiss-ruby/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_endpointObject



40
41
42
# File 'lib/nearmiss-ruby/configurable.rb', line 40

def api_endpoint
  File.join(@api_endpoint, "")
end

#api_keyObject

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_paginateObject

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_optionsObject

Returns the value of attribute connection_options.



4
5
6
# File 'lib/nearmiss-ruby/configurable.rb', line 4

def connection_options
  @connection_options
end

#email=(value) ⇒ Object (writeonly)

Sets the attribute email

Parameters:

  • value

    the value to set the attribute email to.



5
6
7
# File 'lib/nearmiss-ruby/configurable.rb', line 5

def email=(value)
  @email = value
end

#middlewareObject

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

Parameters:

  • value

    the value to set the attribute password to.



5
6
7
# File 'lib/nearmiss-ruby/configurable.rb', line 5

def password=(value)
  @password = value
end

#per_pageObject

Returns the value of attribute per_page.



4
5
6
# File 'lib/nearmiss-ruby/configurable.rb', line 4

def per_page
  @per_page
end

#proxyObject

Returns the value of attribute proxy.



4
5
6
# File 'lib/nearmiss-ruby/configurable.rb', line 4

def proxy
  @proxy
end

#user_agentObject

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

.keysObject



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

Yields:

  • (_self)

Yield Parameters:



27
28
29
# File 'lib/nearmiss-ruby/configurable.rb', line 27

def configure
  yield self
end

#optionsObject



44
45
46
# File 'lib/nearmiss-ruby/configurable.rb', line 44

def options
  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.options[key])
  end
  self
end