Module: Cancando

Includes:
CanCan::Ability
Defined in:
lib/cancando.rb,
lib/cancando/version.rb

Constant Summary collapse

VERSION =
"1.2"

Instance Method Summary collapse

Instance Method Details

#abilitiesObject



14
15
16
# File 'lib/cancando.rb', line 14

def abilities
  @abilities ||= Hash.new { |hash, k| hash[k] = [] }
end

#applyObject



22
23
24
25
# File 'lib/cancando.rb', line 22

def apply
  merge_and_grant(abilities, 'can') if abilities
  merge_and_grant(restrictions, 'cannot') if restrictions
end

#can_do(actions, resource, conditions = {}) ⇒ Object



6
7
8
# File 'lib/cancando.rb', line 6

def can_do(actions, resource, conditions = {})
  add(abilities, actions, resource, conditions)
end

#cannot_do(actions, resource, conditions = {}) ⇒ Object



10
11
12
# File 'lib/cancando.rb', line 10

def cannot_do(actions, resource, conditions = {})
  add(restrictions, actions, resource, conditions)
end

#restrictionsObject



18
19
20
# File 'lib/cancando.rb', line 18

def restrictions
  @restrictions ||= Hash.new { |hash, k| hash[k] = [] }
end