Class: Capistrano::Configuration::Server::Properties
- Inherits:
-
Object
- Object
- Capistrano::Configuration::Server::Properties
show all
- Defined in:
- lib/capistrano/configuration/server.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Properties.
81
82
83
|
# File 'lib/capistrano/configuration/server.rb', line 81
def initialize
@properties = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, value = nil) ⇒ Object
rubocop:disable Style/MethodMissing
115
116
117
118
119
120
121
|
# File 'lib/capistrano/configuration/server.rb', line 115
def method_missing(key, value=nil)
if value
set(lvalue(key), value)
else
fetch(key)
end
end
|
Instance Method Details
#fetch(key) ⇒ Object
98
99
100
|
# File 'lib/capistrano/configuration/server.rb', line 98
def fetch(key)
@properties[key]
end
|
#keys ⇒ Object
110
111
112
|
# File 'lib/capistrano/configuration/server.rb', line 110
def keys
@properties.keys
end
|
#respond_to_missing?(method, _include_all = false) ⇒ Boolean
102
103
104
|
# File 'lib/capistrano/configuration/server.rb', line 102
def respond_to_missing?(method, _include_all=false)
@properties.key?(method) || super
end
|
#roles ⇒ Object
106
107
108
|
# File 'lib/capistrano/configuration/server.rb', line 106
def roles
@roles ||= Set.new
end
|
#set(key, value) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/capistrano/configuration/server.rb', line 85
def set(key, value)
pval = @properties[key]
if pval.is_a?(Hash) && value.is_a?(Hash)
pval.merge!(value)
elsif pval.is_a?(Set) && value.is_a?(Set)
pval.merge(value)
elsif pval.is_a?(Array) && value.is_a?(Array)
pval.concat value
else
@properties[key] = value
end
end
|
#to_h ⇒ Object
rubocop:enable Style/MethodMissing
124
125
126
|
# File 'lib/capistrano/configuration/server.rb', line 124
def to_h
@properties
end
|