Module: Grant::Grantable::InstanceMethods

Defined in:
lib/grant/grantable.rb

Instance Method Summary collapse

Instance Method Details

#grant_createObject



33
# File 'lib/grant/grantable.rb', line 33

def grant_create; grantor_create.authorize!(self); end

#grant_destroyObject



35
# File 'lib/grant/grantable.rb', line 35

def grant_destroy; grantor_destroy.authorize!(self); end

#grant_findObject



32
# File 'lib/grant/grantable.rb', line 32

def grant_find; grantor_find.authorize!(self); end

#grant_updateObject



34
# File 'lib/grant/grantable.rb', line 34

def grant_update; grantor_update.authorize!(self); end

#granted?(action, user = Grant::User.current_user) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/grant/grantable.rb', line 37

def granted?(action, user=Grant::User.current_user)
  grantor = send("grantor_#{action}")
  grantor.authorized?(self, user)
end