Slide 45
Slide 45 text
LAZY SEQUENCES - THE PRESTIGE
STEP WISE LOOKUP
def stages(email)
@stages ||= Enumerator.new do |enumerator|
# Step 1: Only Phone
phone = expensive_phone_lookup(email)
enumerator.yield(:email_only, :phone => phone)
# Step 2: Only Phone Number
location = expensive_location_lookup(email)
enumerator.yield(:location_only, :location => location)
# Step 3: Only Property
property = expensive_property_lookup(email)
enumerator.yield(:property, :property => property)
# Step 4: All Info
enumerator.yield(:all_info, all_info)
end
end