Class: LazyObject

Inherits:
Delegator
  • Object
show all
Defined in:
brew/Library/Homebrew/lazy_object.rb

Instance Method Summary collapse

Constructor Details

#initialize(&callable) ⇒ LazyObject

Returns a new instance of LazyObject



4
5
6
# File 'brew/Library/Homebrew/lazy_object.rb', line 4

def initialize(&callable)
  super(callable)
end

Instance Method Details

#__getobj__Object



8
9
10
11
12
# File 'brew/Library/Homebrew/lazy_object.rb', line 8

def __getobj__
  return @__delegate__ if defined?(@__delegate__)

  @__delegate__ = @__callable__.call
end

#__setobj__(callable) ⇒ Object



14
15
16
# File 'brew/Library/Homebrew/lazy_object.rb', line 14

def __setobj__(callable)
  @__callable__ = callable
end