Sha256: 430ee2f4bd3d647ef95ce209b3826408a4b01396dd3c3dc403503cc4116f070f
Contents?: true
Size: 553 Bytes
Versions: 36
Compression:
Stored size: 553 Bytes
Contents
# frozen_string_literal: true module ActionPolicy module Policy # Per-policy cache for applied rules. # # When you call `apply` twice on the same policy and for the same rule, # the check (and pre-checks) is only called once. module CachedApply def apply(rule) @__rules_cache__ ||= {} if @__rules_cache__.key?(rule) @result = @__rules_cache__[rule] return result.value end super @__rules_cache__[rule] = result result.value end end end end
Version data entries
36 entries across 36 versions & 1 rubygems