Class: Capistrano::Configuration::Server::Properties

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

Instance Method Summary collapse

Constructor Details

#initializeProperties

Returns a new instance of Properties.



69
70
71
# File 'lib/capistrano/configuration/server.rb', line 69

def initialize
  @properties = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, value = nil) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/capistrano/configuration/server.rb', line 102

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

Instance Method Details

#fetch(key) ⇒ Object



86
87
88
# File 'lib/capistrano/configuration/server.rb', line 86

def fetch(key)
  @properties[key]
end

#keysObject



98
99
100
# File 'lib/capistrano/configuration/server.rb', line 98

def keys
  @properties.keys
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/capistrano/configuration/server.rb', line 90

def respond_to?(method)
  @properties.has_key?(method)
end

#rolesObject



94
95
96
# File 'lib/capistrano/configuration/server.rb', line 94

def roles
  @roles ||= Set.new
end

#set(key, value) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/capistrano/configuration/server.rb', line 73

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