Module: Zuul::ActiveRecord::Context::RoleMethods

Defined in:
lib/zuul/active_record/context.rb

Instance Method Summary collapse

Instance Method Details

#allowed?(subject, role) ⇒ Boolean

Checks whether the subject possesses the specified role within the context of self

Returns:

  • (Boolean)


29
30
31
# File 'lib/zuul/active_record/context.rb', line 29

def allowed?(subject, role)
  subject.has_role?(role, self)
end

#destroy_zuul_rolesObject



33
34
35
36
37
38
# File 'lib/zuul/active_record/context.rb', line 33

def destroy_zuul_roles
  auth_scopes.each do |name,scope|
    scope.role_class.where(:context_type => self.class.name, :context_id => self.id).each(&:destroy)
    scope.role_subject_class.where(:context_type => self.class.name, :context_id => self.id).each(&:destroy)
  end
end