Module: AIXM::Memoize
- Included in:
- Component::FATO, Component::FATO::Direction, Component::Frequency, Component::Geometry::Border, Component::Helipad, Component::Lighting, Component::Runway, Component::Runway::Direction, Component::Service, Feature::Address, Feature::Airport, Feature::Airspace, Feature::NavigationalAid::DME, Feature::NavigationalAid::DesignatedPoint, Feature::NavigationalAid::Marker, Feature::NavigationalAid::NDB, Feature::NavigationalAid::TACAN, Feature::NavigationalAid::VOR, Feature::Obstacle, Feature::ObstacleGroup, Feature::Organisation, Feature::Unit
- Defined in:
- lib/aixm/memoize.rb
Overview
Memoize the return value of a specific method across multiple instances for the duration of a block.
The method signature is taken into account, therefore calls of the same method with different positional and/or keyword arguments are cached independently. On the other hand, when calling the method with a block, no memoization is performed at all.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.cache ⇒ Object
84 85 86 |
# File 'lib/aixm/memoize.rb', line 84 def cache (@cache[@method] ||= {}) if @method end |
.included(base) ⇒ Object
71 72 73 74 |
# File 'lib/aixm/memoize.rb', line 71 def included(base) base.extend(ClassMethods) @cache = {} end |
.method(method) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/aixm/memoize.rb', line 76 def method(method) @method = method @cache[@method] = {} yield ensure @method = nil end |