Module: KittyPolicy::DSL

Defined in:
lib/kitty_policy/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



5
6
7
# File 'lib/kitty_policy/dsl.rb', line 5

def self.extended(base)
  base.extend(base)
end

Instance Method Details

#authorize!(*args) ⇒ Object

Raises:



17
18
19
# File 'lib/kitty_policy/dsl.rb', line 17

def authorize!(*args)
  raise AccessDenied.new(*args) unless can?(*args)
end

#can?(user, action, subject = :empty) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
# File 'lib/kitty_policy/dsl.rb', line 9

def can?(user, action, subject = :empty)
  if subject == :empty
    public_send Helper.method_name(action), user
  else
    public_send Helper.method_name(action, subject), user, subject
  end
end