Class: Rubber::Configuration::RoleItem
- Inherits:
-
Object
- Object
- Rubber::Configuration::RoleItem
- Defined in:
- lib/rubber/instance.rb
Overview
The configuration for a single role contained in the list of roles in InstanceItem
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(rhs) ⇒ Object
- #eql?(rhs) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(name, options = {}) ⇒ RoleItem
constructor
A new instance of RoleItem.
- #to_s ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ RoleItem
Returns a new instance of RoleItem.
363 364 365 366 |
# File 'lib/rubber/instance.rb', line 363 def initialize(name, ={}) @name = name @options = || {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
317 318 319 |
# File 'lib/rubber/instance.rb', line 317 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
317 318 319 |
# File 'lib/rubber/instance.rb', line 317 def @options end |
Class Method Details
.expand_role_dependencies(roles, dependency_map, expanded = []) ⇒ Object
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/rubber/instance.rb', line 319 def self.(roles, dependency_map, =[]) roles = Array(roles) if .size == 0 common_deps = Array(dependency_map[RoleItem.new('common')]) roles.concat(common_deps) end roles.each do |role| unless .include?(role) << role needed = dependency_map[role] (needed, dependency_map, ) end end return end |
.parse(str) ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/rubber/instance.rb', line 338 def self.parse(str) data = str.split(':') role = Rubber::Configuration::RoleItem.new(data[0]) if data[1] data[1].split(';').each do |pair| p = pair.split('=') val = case p[1] when 'true' then true when 'false' then false else p[1] end role.[p[0]] = val end end return role end |
Instance Method Details
#<=>(rhs) ⇒ Object
377 378 379 |
# File 'lib/rubber/instance.rb', line 377 def <=>(rhs) return @name <=> rhs.name end |
#eql?(rhs) ⇒ Boolean Also known as: ==
368 369 370 |
# File 'lib/rubber/instance.rb', line 368 def eql?(rhs) rhs && @name == rhs.name && @options == rhs. end |
#hash ⇒ Object
373 374 375 |
# File 'lib/rubber/instance.rb', line 373 def hash @name.hash end |
#to_s ⇒ Object
354 355 356 357 358 359 360 361 |
# File 'lib/rubber/instance.rb', line 354 def to_s str = @name @options.each_with_index do |kv, i| str += (i == 0 ? ':' : ';') str += "#{kv[0]}=#{kv[1]}" end return str end |