| Path: | lib/grit/lazy.rb |
| Last Update: | Tue Oct 21 09:18:51 -0700 2008 |
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