Module: Ark::Configurable

Included in:
Ark, Client
Defined in:
lib/ark/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ipObject

Returns the value of attribute ip.



3
4
5
# File 'lib/ark/configurable.rb', line 3

def ip
  @ip
end

#nethashObject

Returns the value of attribute nethash.



3
4
5
# File 'lib/ark/configurable.rb', line 3

def nethash
  @nethash
end

#portObject

Returns the value of attribute port.



3
4
5
# File 'lib/ark/configurable.rb', line 3

def port
  @port
end

#versionObject

Returns the value of attribute version.



3
4
5
# File 'lib/ark/configurable.rb', line 3

def version
  @version
end

Class Method Details

.keysObject



6
7
8
9
10
11
12
13
# File 'lib/ark/configurable.rb', line 6

def keys
  @keys ||= [
    :ip,
    :port,
    :nethash,
    :version
  ]
end

Instance Method Details

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

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



17
18
19
# File 'lib/ark/configurable.rb', line 17

def configure
  yield self
end

#reset!Object Also known as: setup

Reset configuration options to default values



22
23
24
25
26
27
# File 'lib/ark/configurable.rb', line 22

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

#same_options?(opts) ⇒ Boolean

Compares client options to a Hash of requested options

Parameters:

  • opts (Hash)

    Options to compare with current client options

Returns:

  • (Boolean)


34
35
36
# File 'lib/ark/configurable.rb', line 34

def same_options?(opts)
  opts.hash == options.hash
end