Module: Protector::CanCan::Resource

Extended by:
ActiveSupport::Concern
Defined in:
lib/protector/cancan/resource.rb

Instance Method Summary collapse

Instance Method Details

#load_collection_with_protectorObject



20
21
22
23
24
25
26
27
28
# File 'lib/protector/cancan/resource.rb', line 20

def load_collection_with_protector
  resource = resource_base

  if resource_protectable? resource
    resource
  else
    load_collection_without_protector
  end
end

#load_collection_with_protector?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
# File 'lib/protector/cancan/resource.rb', line 30

def load_collection_with_protector?
  if resource_protectable? resource_base
    true
  else
    load_collection_without_protector?
  end
end

#resource_base_with_protectorObject



10
11
12
13
14
15
16
17
18
# File 'lib/protector/cancan/resource.rb', line 10

def resource_base_with_protector
  resource = resource_base_without_protector

  if resource_protectable? resource
    resource.restrict!(current_ability.protector_subject)
  else
    resource
  end
end