class RolifyHier::HierRole
Attributes
name[R]
sub[R]
Public Class Methods
[](name)
click to toggle source
# File lib/rolify_hier/hier_role.rb, line 5 def self.[](name) if @@roles.key? name @@roles[name] else role = self.new(name) @@roles[name] = role role end end
new(name)
click to toggle source
# File lib/rolify_hier/hier_role.rb, line 18 def initialize(name) raise ArgumentError, 'name is nil' if name.nil? @name = name @sub = Set.new end
Public Instance Methods
<<(o)
click to toggle source
# File lib/rolify_hier/hier_role.rb, line 24 def <<(o) check_arg_type(o) include(o) end
include(o)
click to toggle source
# File lib/rolify_hier/hier_role.rb, line 29 def include(o) check_arg_type(o) @sub << o o end
include?(o)
click to toggle source
# File lib/rolify_hier/hier_role.rb, line 35 def include?(o) check_arg_type(o) @sub.include?(o) end
reachable_roles()
click to toggle source
# File lib/rolify_hier/hier_role.rb, line 46 def reachable_roles list = [self] @sub.each do |e| list += e.reachable_roles end list end
remove(o)
click to toggle source
Not hierarchic
# File lib/rolify_hier/hier_role.rb, line 41 def remove(o) check_arg_type(o) @sub.remove(o) end
Private Instance Methods
check_arg_type(o)
click to toggle source
# File lib/rolify_hier/hier_role.rb, line 55 def check_arg_type(o) raise 'the argument is not an HierRole class instance' unless o.instance_of?(HierRole) end