Module: Paginae::Memoizer

Included in:
NodeBuilder, ReaderBuilder
Defined in:
lib/paginae/memoizer.rb

Instance Method Summary collapse

Instance Method Details

#define_memoized_method(name) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/paginae/memoizer.rb', line 5

def define_memoized_method(name)
  define_method name do
    return instance_variable_get("@#{name}") if instance_variable_defined?("@#{name}")

    instance_variable_set("@#{name}", yield(self))
  end
end