Class: CanCan::ModelAdapters::ConditionsNormalizer
- Inherits:
-
Object
- Object
- CanCan::ModelAdapters::ConditionsNormalizer
- Defined in:
- lib/cancan/model_adapters/conditions_normalizer.rb
Class Method Summary collapse
Class Method Details
.normalize(model_class, rules) ⇒ Object
9 10 11 |
# File 'lib/cancan/model_adapters/conditions_normalizer.rb', line 9 def normalize(model_class, rules) rules.each { |rule| rule.conditions = normalize_conditions(model_class, rule.conditions) } end |
.normalize_conditions(model_class, conditions) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cancan/model_adapters/conditions_normalizer.rb', line 13 def normalize_conditions(model_class, conditions) return conditions unless conditions.is_a? Hash conditions.each_with_object({}) do |(key, value), result_hash| if value.is_a? Hash result_hash.merge!(calculate_result_hash(model_class, key, value)) else result_hash[key] = value end result_hash end end |