class Casbin::Model::Assertion
Attributes
key[RW]
policy[RW]
rm[RW]
tokens[RW]
value[RW]
Public Class Methods
new(hash = {})
click to toggle source
# File lib/casbin-ruby/model/assertion.rb, line 10 def initialize(hash = {}) @key = hash[:key].to_s @value = hash[:value].to_s @tokens = [*hash[:tokens]] @policy = [*hash[:policy]] end
Public Instance Methods
build_role_links(rm)
click to toggle source
# File lib/casbin-ruby/model/assertion.rb, line 17 def build_role_links(rm) @rm = rm count = value.count('_') policy.each do |rule| raise 'the number of "_" in role definition should be at least 2' if count < 2 raise 'grouping policy elements do not meet role definition' if rule.size < count rm.add_link(*rule) Logger.info("Role links for: #{key}") rm.print_roles end end