Last Modified
2012-01-14 09:04:07 +0900
Requires

Description

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

> 2