cancancan 2.3.0 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cancancan.gemspec +6 -5
- data/init.rb +2 -0
- data/lib/cancan.rb +6 -0
- data/lib/cancan/ability.rb +54 -24
- data/lib/cancan/ability/actions.rb +2 -0
- data/lib/cancan/ability/rules.rb +14 -6
- data/lib/cancan/ability/strong_parameter_support.rb +41 -0
- data/lib/cancan/class_matcher.rb +26 -0
- data/lib/cancan/conditions_matcher.rb +25 -12
- data/lib/cancan/config.rb +54 -0
- data/lib/cancan/controller_additions.rb +4 -1
- data/lib/cancan/controller_resource.rb +6 -0
- data/lib/cancan/controller_resource_builder.rb +2 -0
- data/lib/cancan/controller_resource_finder.rb +2 -0
- data/lib/cancan/controller_resource_loader.rb +4 -0
- data/lib/cancan/controller_resource_name_finder.rb +2 -0
- data/lib/cancan/controller_resource_sanitizer.rb +2 -0
- data/lib/cancan/exceptions.rb +18 -2
- data/lib/cancan/matchers.rb +3 -0
- data/lib/cancan/model_adapters/abstract_adapter.rb +3 -1
- data/lib/cancan/model_adapters/active_record_4_adapter.rb +26 -25
- data/lib/cancan/model_adapters/active_record_5_adapter.rb +21 -26
- data/lib/cancan/model_adapters/active_record_adapter.rb +56 -14
- data/lib/cancan/model_adapters/conditions_extractor.rb +3 -3
- data/lib/cancan/model_adapters/conditions_normalizer.rb +49 -0
- data/lib/cancan/model_adapters/default_adapter.rb +2 -0
- data/lib/cancan/model_adapters/sti_normalizer.rb +39 -0
- data/lib/cancan/model_additions.rb +2 -0
- data/lib/cancan/parameter_validators.rb +9 -0
- data/lib/cancan/relevant.rb +29 -0
- data/lib/cancan/rule.rb +67 -23
- data/lib/cancan/rules_compressor.rb +3 -0
- data/lib/cancan/unauthorized_message_resolver.rb +24 -0
- data/lib/cancan/version.rb +3 -1
- data/lib/cancancan.rb +2 -0
- data/lib/generators/cancan/ability/ability_generator.rb +3 -1
- data/lib/generators/cancan/ability/templates/ability.rb +2 -0
- metadata +37 -30
- data/lib/cancan/model_adapters/can_can/model_adapters/active_record_adapter/joins.rb +0 -39
@@ -1,39 +0,0 @@
|
|
1
|
-
module CanCan
|
2
|
-
module ModelAdapters
|
3
|
-
module ActiveRecordAdapter
|
4
|
-
module Joins
|
5
|
-
# Returns the associations used in conditions for the :joins option of a search.
|
6
|
-
# See ModelAdditions#accessible_by
|
7
|
-
def joins
|
8
|
-
joins_hash = {}
|
9
|
-
@rules.reverse.each do |rule|
|
10
|
-
merge_joins(joins_hash, rule.associations_hash)
|
11
|
-
end
|
12
|
-
clean_joins(joins_hash) unless joins_hash.empty?
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
# Removes empty hashes and moves everything into arrays.
|
18
|
-
def clean_joins(joins_hash)
|
19
|
-
joins = []
|
20
|
-
joins_hash.each do |name, nested|
|
21
|
-
joins << (nested.empty? ? name : { name => clean_joins(nested) })
|
22
|
-
end
|
23
|
-
joins
|
24
|
-
end
|
25
|
-
|
26
|
-
# Takes two hashes and does a deep merge.
|
27
|
-
def merge_joins(base, add)
|
28
|
-
add.each do |name, nested|
|
29
|
-
if base[name].is_a?(Hash)
|
30
|
-
merge_joins(base[name], nested) unless nested.empty?
|
31
|
-
else
|
32
|
-
base[name] = nested
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|