Module: Plat::Role

Defined in:
lib/plat/role.rb,
lib/plat/role/db.rb,
lib/plat/role/cpu.rb,
lib/plat/role/mail.rb,
lib/plat/role/basic.rb,
lib/plat/role/cache.rb,
lib/plat/role/files.rb,
lib/plat/role/iam_role.rb

Defined Under Namespace

Classes: Basic, Cache, Cpu, Db, Files, IAMRole, Mail

Class Method Summary collapse

Class Method Details

.create(layout, role, options) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/plat/role.rb', line 46

def self.create(layout,role,options)
  if type = options[:type]
    raise ArgumentError.new "Wrong type for role #{@role}: #{options[:type]}" unless registered_types.member?(type)
  else
    rtype = role.downcase.to_sym
    type = registered_types.member?(rtype) ? rtype : :cpu
  end
  registered_types[type].new(layout,role,options)
end

.register(type, cname) ⇒ Object



42
43
44
# File 'lib/plat/role.rb', line 42

def self.register(type,cname)
  registered_types[type] = cname
end

.registered_typesObject



39
40
41
# File 'lib/plat/role.rb', line 39

def self.registered_types
  @registered_types ||= {}
end