Module: DeepCover::Memoize

Included in:
Analyser::StatsBase, Coverage::Analysis, Node, Reporter::Base, Reporter::HTML::Site
Defined in:
lib/deep_cover/memoize.rb

Overview

Memoize is a quick way to prepend a module that defines the memoized methods as ‘@_cache ||= super.freeze` It also refines `freeze` to precache memoized methods

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
# File 'lib/deep_cover/memoize.rb', line 11

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#freezeObject



15
16
17
18
19
20
# File 'lib/deep_cover/memoize.rb', line 15

def freeze
  self.class.memoized.each do |method|
    send method
  end
  super
end