class Admission::Privilege
Constants
- BASE_LEVEL_NAME
- RESERVED_ID
- SEPARATOR
- TOP_LEVEL_KEY
Attributes
context[R]
hash[R]
inherited[R]
level[R]
name[R]
Public Class Methods
new(name, level=nil)
click to toggle source
# File lib/admission/privilege.rb, line 11 def initialize name, level=nil @name = name.to_sym @level = level ? level.to_sym : BASE_LEVEL_NAME @hash = [@name, @level].hash end
split_text_key(value)
click to toggle source
# File lib/admission/privilege.rb, line 42 def self.split_text_key value return value.split(SEPARATOR) end
Public Instance Methods
dup_with_context(context=nil)
click to toggle source
# File lib/admission/privilege.rb, line 21 def dup_with_context context=nil return self if context.nil? with_context = dup with_context.instance_variable_set :@context, context with_context end
eql?(other)
click to toggle source
# File lib/admission/privilege.rb, line 28 def eql? other hash == other.hash end
eql_or_inherits?(sought)
click to toggle source
# File lib/admission/privilege.rb, line 32 def eql_or_inherits? sought return true if eql? sought return false unless inherited inherited.any?{|pi| pi.eql_or_inherits? sought} end
inherits_from(*privileges)
click to toggle source
# File lib/admission/privilege.rb, line 17 def inherits_from *privileges @inherited = privileges end
inspect()
click to toggle source
# File lib/admission/privilege.rb, line 46 def inspect "#<#{[ 'Privilege', "key=#{text_key}", (inherited && "inherited=[#{inherited.map(&:text_key).join ','}]") ].compact.join ' '}>" end
text_key()
click to toggle source
# File lib/admission/privilege.rb, line 38 def text_key @text_key ||= level == BASE_LEVEL_NAME ? name.to_s : "#{name}#{SEPARATOR}#{level}" end
to_s()
click to toggle source
# File lib/admission/privilege.rb, line 54 def to_s [ "privilege #{text_key}", (context && ", context #{context}") ].join '' end