Module: IronBank::Associations

Included in:
Resource
Defined in:
lib/iron_bank/associations.rb

Overview

Define association methods for Zuora resources.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#with_memoization(name) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/iron_bank/associations.rb', line 60

def with_memoization(name)
  # NOTE: We use `instance_variables.include?` instead of `defined?`.
  # Later it will always evaluate to `true` because it's an expression.
  return instance_variable_get(:"@#{name}") if instance_variables.include?(:"@#{name}")

  memoizable = yield
  instance_variable_set(:"@#{name}", memoizable)
end