Module: Toolhound::Configurable
Instance Attribute Summary collapse
-
#dataserver ⇒ Object
writeonly
attr_accessor :auto_paginate, :per_page.
-
#password ⇒ Object
writeonly
attr_accessor :auto_paginate, :per_page.
-
#port ⇒ Object
writeonly
attr_accessor :auto_paginate, :per_page.
-
#timeout ⇒ Object
writeonly
attr_accessor :auto_paginate, :per_page.
-
#username ⇒ Object
writeonly
attr_accessor :auto_paginate, :per_page.
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Set configuration options using a block.
-
#options ⇒ Object
def api_endpoint File.join(@api_endpoint, “”) end.
-
#reset! ⇒ Object
(also: #setup)
Reset configuration options to default values.
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
.keys ⇒ Object
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
22 23 24 |
# File 'lib/toolhound-ruby/configurable.rb', line 22 def configure yield self end |
#options ⇒ Object
def api_endpoint
File.join(@api_endpoint, "")
end
39 40 41 |
# File 'lib/toolhound-ruby/configurable.rb', line 39 def 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.[key]) end self end |