Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. # Give a block to be evaluated lazily.
  2. class DelayedResult < BasicObject
  3. def initialize(&block)
  4. @block = block
  5. end
  6.  
  7. def method_missing(m, *a, &b)
  8. @obj = @block.call() unless defined? @obj
  9. @obj.__send__(m, *a, &b)
  10. end
  11. end
Add Comment
Please, Sign In to add comment