Module: Granted::Grantee

Extended by:
ActiveSupport::Concern
Defined in:
lib/granted/modules/grantee.rb

Instance Method Summary collapse

Instance Method Details

#grant(*rights) ⇒ Object



4
5
6
7
8
9
# File 'lib/granted/modules/grantee.rb', line 4

def grant(*rights)
  Granted::Granter.new
                  .grant
                  .rights(rights)
                  .to(self)
end

#grants_for(subject) ⇒ Object



18
19
20
21
22
# File 'lib/granted/modules/grantee.rb', line 18

def grants_for(subject)
  grants.subject(subject).map do |g|
    grant_class_name_to_symbol(g.type)
  end.sort
end

#revoke(*rights) ⇒ Object



11
12
13
14
15
16
# File 'lib/granted/modules/grantee.rb', line 11

def revoke(*rights)
  Granted::Granter.new
                  .revoke
                  .rights(rights)
                  .to(self)
end