Class: Luban::Deployment::Configuration::Server
- Inherits:
-
SSHKit::Host
- Object
- SSHKit::Host
- Luban::Deployment::Configuration::Server
- Defined in:
- lib/luban/deployment/configuration/server.rb
Instance Attribute Summary collapse
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object (also: #fetch)
- #[]=(key, value) ⇒ Object (also: #set)
- #add_cronjob(cronjob) ⇒ Object (also: #cronjob=)
- #add_cronjobs(cronjobs) ⇒ Object (also: #cronjobs=)
- #add_properties(_properties) ⇒ Object
- #add_role(role) ⇒ Object
- #add_roles(roles) ⇒ Object (also: #roles=)
- #cronjobs ⇒ Object
- #has_role?(role) ⇒ Boolean
- #primary? ⇒ Boolean
- #properties ⇒ Object
Instance Attribute Details
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
7 8 9 |
# File 'lib/luban/deployment/configuration/server.rb', line 7 def roles @roles end |
Class Method Details
Instance Method Details
#[](key) ⇒ Object Also known as: fetch
37 38 39 |
# File 'lib/luban/deployment/configuration/server.rb', line 37 def [](key) properties[key] end |
#[]=(key, value) ⇒ Object Also known as: set
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/luban/deployment/configuration/server.rb', line 42 def []=(key, value) if respond_to?("#{key}=") send("#{key}=", value) else 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 end |
#add_cronjob(cronjob) ⇒ Object Also known as: cronjob=
77 78 79 |
# File 'lib/luban/deployment/configuration/server.rb', line 77 def add_cronjob(cronjob) cronjobs.add(cronjob) end |
#add_cronjobs(cronjobs) ⇒ Object Also known as: cronjobs=
72 73 74 |
# File 'lib/luban/deployment/configuration/server.rb', line 72 def add_cronjobs(cronjobs) cronjobs.each { |cronjob| add_cronjob(cronjob) } end |
#add_properties(_properties) ⇒ Object
60 61 62 |
# File 'lib/luban/deployment/configuration/server.rb', line 60 def add_properties(_properties) _properties.each { |k, v| self[k] = v } end |
#add_role(role) ⇒ Object
25 26 27 |
# File 'lib/luban/deployment/configuration/server.rb', line 25 def add_role(role) roles.add(role.to_sym) end |
#add_roles(roles) ⇒ Object Also known as: roles=
20 21 22 |
# File 'lib/luban/deployment/configuration/server.rb', line 20 def add_roles(roles) roles.each { |role| add_role(role) } end |
#cronjobs ⇒ Object
68 69 70 |
# File 'lib/luban/deployment/configuration/server.rb', line 68 def cronjobs self[:cronjobs] end |
#has_role?(role) ⇒ Boolean
29 30 31 |
# File 'lib/luban/deployment/configuration/server.rb', line 29 def has_role?(role) roles.include? role.to_sym end |
#primary? ⇒ Boolean
64 65 66 |
# File 'lib/luban/deployment/configuration/server.rb', line 64 def primary? self[:primary] end |
#properties ⇒ Object
33 34 35 |
# File 'lib/luban/deployment/configuration/server.rb', line 33 def properties @properties ||= { :roles => Set.new, :cronjobs => Set.new } end |