cancancan 2.3.0 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/cancancan.gemspec +6 -5
  3. data/init.rb +2 -0
  4. data/lib/cancan.rb +6 -0
  5. data/lib/cancan/ability.rb +54 -24
  6. data/lib/cancan/ability/actions.rb +2 -0
  7. data/lib/cancan/ability/rules.rb +14 -6
  8. data/lib/cancan/ability/strong_parameter_support.rb +41 -0
  9. data/lib/cancan/class_matcher.rb +26 -0
  10. data/lib/cancan/conditions_matcher.rb +25 -12
  11. data/lib/cancan/config.rb +54 -0
  12. data/lib/cancan/controller_additions.rb +4 -1
  13. data/lib/cancan/controller_resource.rb +6 -0
  14. data/lib/cancan/controller_resource_builder.rb +2 -0
  15. data/lib/cancan/controller_resource_finder.rb +2 -0
  16. data/lib/cancan/controller_resource_loader.rb +4 -0
  17. data/lib/cancan/controller_resource_name_finder.rb +2 -0
  18. data/lib/cancan/controller_resource_sanitizer.rb +2 -0
  19. data/lib/cancan/exceptions.rb +18 -2
  20. data/lib/cancan/matchers.rb +3 -0
  21. data/lib/cancan/model_adapters/abstract_adapter.rb +3 -1
  22. data/lib/cancan/model_adapters/active_record_4_adapter.rb +26 -25
  23. data/lib/cancan/model_adapters/active_record_5_adapter.rb +21 -26
  24. data/lib/cancan/model_adapters/active_record_adapter.rb +56 -14
  25. data/lib/cancan/model_adapters/conditions_extractor.rb +3 -3
  26. data/lib/cancan/model_adapters/conditions_normalizer.rb +49 -0
  27. data/lib/cancan/model_adapters/default_adapter.rb +2 -0
  28. data/lib/cancan/model_adapters/sti_normalizer.rb +39 -0
  29. data/lib/cancan/model_additions.rb +2 -0
  30. data/lib/cancan/parameter_validators.rb +9 -0
  31. data/lib/cancan/relevant.rb +29 -0
  32. data/lib/cancan/rule.rb +67 -23
  33. data/lib/cancan/rules_compressor.rb +3 -0
  34. data/lib/cancan/unauthorized_message_resolver.rb +24 -0
  35. data/lib/cancan/version.rb +3 -1
  36. data/lib/cancancan.rb +2 -0
  37. data/lib/generators/cancan/ability/ability_generator.rb +3 -1
  38. data/lib/generators/cancan/ability/templates/ability.rb +2 -0
  39. metadata +37 -30
  40. 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