Sha256: 491f08914964d784f87121d44c282c41d006f101eefb19637f8a073124ac5b69
Contents?: true
Size: 529 Bytes
Versions: 2
Compression:
Stored size: 529 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_r(rule) @__rules_cache__ ||= {} if @__rules_cache__.key?(rule) return @__rules_cache__[rule] end super.tap do |result| @__rules_cache__[rule] = result end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
action_policy-0.7.4 | lib/action_policy/policy/cached_apply.rb |
action_policy-0.7.3 | lib/action_policy/policy/cached_apply.rb |