Module: Motor::CancanUtils::AbilityPatch

Included in:
CanManageAll
Defined in:
lib/motor/cancan_utils/ability_patch.rb

Instance Method Summary collapse

Instance Method Details

#rules_hashObject


20
21
22
# File 'lib/motor/cancan_utils/ability_patch.rb', line 20

def rules_hash
  serialized_rules.hash
end

#serialized_rulesObject


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/motor/cancan_utils/ability_patch.rb', line 6

def serialized_rules
  return [] unless @rules

  @rules.map do |rule|
    {
      base_behavior: rule.base_behavior,
      actions: expand_actions(rule.actions),
      subjects: rule.subjects.map(&:to_s),
      attributes: rule.attributes,
      conditions: rule.conditions.as_json
    }
  end
end