Class: NetworkExecutive::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/network_executive/configuration.rb

Constant Summary collapse

@@defaults =
HashWithIndifferentAccess.new(
  name: 'My Network'
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
# File 'lib/network_executive/configuration.rb', line 11

def initialize
  @@defaults.dup.each_pair { |k, v| self.send "#{k}=", v }
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/network_executive/configuration.rb', line 5

def name
  @name
end

Instance Method Details

#attributesObject Also known as: to_hash



19
20
21
22
23
# File 'lib/network_executive/configuration.rb', line 19

def attributes
  self.class.defaults.keys.each_with_object(HashWithIndifferentAccess.new) do |k, hash|
    hash[k] = self.send k
  end
end

#defaultsObject



15
16
17
# File 'lib/network_executive/configuration.rb', line 15

def defaults
  @@defaults
end