Module: Toolhound::Configurable

Included in:
Toolhound, Client
Defined in:
lib/toolhound-ruby/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataserver=(value) ⇒ Object (writeonly)

attr_accessor :auto_paginate, :per_page



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

def dataserver=(value)
  @dataserver = value
end

#password=(value) ⇒ Object (writeonly)

attr_accessor :auto_paginate, :per_page



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

def password=(value)
  @password = value
end

#port=(value) ⇒ Object (writeonly)

attr_accessor :auto_paginate, :per_page



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

def port=(value)
  @port = value
end

#timeout=(value) ⇒ Object (writeonly)

attr_accessor :auto_paginate, :per_page



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

def timeout=(value)
  @timeout = value
end

#username=(value) ⇒ Object (writeonly)

attr_accessor :auto_paginate, :per_page



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

def username=(value)
  @username = value
end

Class Method Details

.keysObject



10
11
12
13
14
15
16
17
18
# File 'lib/toolhound-ruby/configurable.rb', line 10

def keys
  @keys ||= [
    :dataserver,
    :port,
    :username,
    :password,
    :timeout
  ]
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



22
23
24
# File 'lib/toolhound-ruby/configurable.rb', line 22

def configure
  yield self
end

#optionsObject

def api_endpoint

File.join(@api_endpoint, "")

end



39
40
41
# File 'lib/toolhound-ruby/configurable.rb', line 39

def options
  Hash[Toolhound::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}]
end

#reset!Object Also known as: setup

Reset configuration options to default values



27
28
29
30
31
32
# File 'lib/toolhound-ruby/configurable.rb', line 27

def reset!
  Toolhound::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", Toolhound::Default.options[key])
  end
  self
end