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.



82
83
84
# File 'lib/capistrano/configuration/server.rb', line 82

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



116
117
118
119
120
121
122
# File 'lib/capistrano/configuration/server.rb', line 116

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

Instance Method Details

#fetch(key) ⇒ Object



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

def fetch(key)
  @properties[key]
end

#keysObject



111
112
113
# File 'lib/capistrano/configuration/server.rb', line 111

def keys
  @properties.keys
end

#respond_to_missing?(method, _include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/capistrano/configuration/server.rb', line 103

def respond_to_missing?(method, _include_all=false)
  @properties.key?(method) || super
end

#rolesObject



107
108
109
# File 'lib/capistrano/configuration/server.rb', line 107

def roles
  @roles ||= Set.new
end

#set(key, value) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/capistrano/configuration/server.rb', line 86

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_hObject

rubocop:enable Style/MethodMissing



125
126
127
# File 'lib/capistrano/configuration/server.rb', line 125

def to_h
  @properties
end