Class: RolePermit::User

Inherits:
Base
  • Object
show all
Defined in:
lib/permits.rb,
lib/generators/auth_assist/test.rb,
lib/generators/auth_assist/templates/permits.rb

Instance Attribute Summary

Attributes inherited from Base

#ability

Instance Method Summary collapse

Methods inherited from Base

#can, #cannot, #owns

Constructor Details

#initialize(ability) ⇒ User

Returns a new instance of User.



42
43
44
# File 'lib/permits.rb', line 42

def initialize(ability)
  super
end

Instance Method Details

#permit?(user, request) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/permits.rb', line 46

def permit?(user) 
  super
  return if user.role? :admin
  can :read, :all           
  
  # user.owns(Comment)
  
  # a user can manage comments he/she created
  # can :manage, Comment do |comment|
  #   comment.try(:user) == user
  # end            
  
  # can :create, Comment
end