require 'roles_generic/roles_base' class Role attr_accessor :name def self.find_role role_name role_name = Roles::Generic::RoleUtil.extract_role(role_name) roles.to_a.select do |r| r.name.to_sym == role_name.to_sym end.first end def self.find_roles *role_names result = Set.new role_names.to_symbols.each do |role_name| found_role = find_role(role_name) result << found_role if found_role end result end class << self attr_accessor :roles def all roles.to_a end def names roles.map(&:name) end end def initialize name @name = name self.class.roles ||= Set.new self.class.roles << self end end