Module: ActionPolicy::Policy::Cache::ClassMethods

Defined in:
lib/action_policy/policy/cache.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#cache(*rules, **options) ⇒ Object



83
84
85
86
87
# File 'lib/action_policy/policy/cache.rb', line 83

def cache(*rules, **options)
  rules.each do |rule|
    cached_rules[rule] = options
  end
end

#cached_rulesObject



89
90
91
92
93
94
95
96
97
# File 'lib/action_policy/policy/cache.rb', line 89

def cached_rules
  return @cached_rules if instance_variable_defined?(:@cached_rules)

  @cached_rules = if superclass.respond_to?(:cached_rules)
    superclass.cached_rules.dup
  else
    {}
  end
end