Path: | lib/grit/lazy.rb |
Last Update: | Sat Oct 31 01:21:05 +0100 2009 |
Allows attributes to be declared as lazy, meaning that they won‘t be computed until they are asked for.
Works by delegating each lazy_reader to a cached lazy_source method.
class Person
lazy_reader :eyes def lazy_source OpenStruct.new(:eyes => 2) end
end
>> Person.new.eyes