Module: Factbase::CachedTerm

Defined in:
lib/factbase/cached/cached_term.rb

Overview

Term with a cache.

Author

Yegor Bugayenko (yegor256@gmail.com)

Copyright

Copyright © 2024-2025 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Instance Method Details

#evaluate(fact, maps, fb) ⇒ bool

Does it match the fact?

Parameters:

Returns:

  • (bool)

    TRUE if matches


18
19
20
21
22
23
24
# File 'lib/factbase/cached/cached_term.rb', line 18

def evaluate(fact, maps, fb)
  return super unless static? && !abstract?
  key = [maps.object_id, to_s]
  before = @cache[key]
  @cache[key] = super if before.nil?
  @cache[key]
end