Module: AnnotationSecurity::Role

Defined in:
lib/annotation_security/includes/role.rb

Overview

AnnotationSecurity::Role

This module should be included by all role classes to enable full support of all features.

A role class is a domain class that represents user roles and does not extend the user class. It should have the method #user that returns the user object it belongs to.

Instance Method Summary collapse

Instance Method Details

#==(obj) ⇒ Object

If obj is a UserWrapper, extract the role before comparing



26
27
28
29
# File 'lib/annotation_security/includes/role.rb', line 26

def ==(obj)
  obj = obj.__role__ if obj.is_a? AnnotationSecurity::UserWrapper
  super(obj)
end

#is_user?(user) ⇒ Boolean

Returns true if this belongs to the user given as parameter.

Required to have a common interface with AnnotationSecurity::User.

Returns:

  • (Boolean)


20
21
22
# File 'lib/annotation_security/includes/role.rb', line 20

def is_user?(user)
  self.user == user
end