Class: CanCan::ModelAdapters::StiNormalizer
- Inherits:
-
Object
- Object
- CanCan::ModelAdapters::StiNormalizer
- Defined in:
- lib/cancan/model_adapters/sti_normalizer.rb
Class Method Summary collapse
Class Method Details
.normalize(rules) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cancan/model_adapters/sti_normalizer.rb', line 9 def normalize(rules) rules_cache = [] return unless defined?(ActiveRecord::Base) rules.delete_if do |rule| subjects = rule.subjects.select do |subject| update_rule(subject, rule, rules_cache) end subjects.length == rule.subjects.length end rules_cache.each { |rule| rules.push(rule) } end |