Module: Mnam::Configurable

Included in:
Mnam, Client
Defined in:
lib/mnam/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#nethashObject

Returns the value of attribute nethash.



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

def nethash
  @nethash
end

#network_addressObject

Returns the value of attribute network_address.



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

def network_address
  @network_address
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.keysObject



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

def keys
  @keys ||= [
    :host,
    :nethash,
    :version,
    :network_address
  ]
end

Instance Method Details

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

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



17
18
19
# File 'lib/mnam/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/mnam/configurable.rb', line 22

def reset!
  Mnam::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", Mnam::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/mnam/configurable.rb', line 34

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