Class: Naginata::Configuration::NagiosServer::Properties

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

Instance Method Summary collapse

Constructor Details

#initializeProperties

Returns a new instance of Properties.



38
39
40
# File 'lib/naginata/configuration/nagios_server.rb', line 38

def initialize
  @properties = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, value = nil) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/naginata/configuration/nagios_server.rb', line 65

def method_missing(key, value=nil)
  if value
    set(lvalue(key), value)
  else
    fetch(key)
  end
end

Instance Method Details

#fetch(key) ⇒ Object



53
54
55
# File 'lib/naginata/configuration/nagios_server.rb', line 53

def fetch(key)
  @properties[key]
end

#keysObject



61
62
63
# File 'lib/naginata/configuration/nagios_server.rb', line 61

def keys
  @properties.keys
end

#respond_to?(method, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/naginata/configuration/nagios_server.rb', line 57

def respond_to?(method, include_all=false)
  @properties.has_key?(method)
end

#set(key, value) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/naginata/configuration/nagios_server.rb', line 42

def set(key, value)
  pval = @properties[key]
  if pval.is_a? Hash and value.is_a? Hash
    pval.merge!(value)
  elsif pval.is_a? Array and value.is_a? Array
    pval.concat value
  else
    @properties[key] = value
  end
end