Class: LazyObject Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An object which lazily evaluates its inner block only once a method is called on it.

Instance Method Summary collapse

Constructor Details

#initialize(&callable) ⇒ LazyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LazyObject.


7
8
9
# File 'Library/Homebrew/lazy_object.rb', line 7

def initialize(&callable)
  super(callable)
end

Instance Method Details

#__getobj__Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


11
12
13
14
15
# File 'Library/Homebrew/lazy_object.rb', line 11

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

  @__delegate__ = @__callable__.call
end

#__setobj__(callable) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


17
18
19
# File 'Library/Homebrew/lazy_object.rb', line 17

def __setobj__(callable)
  @__callable__ = callable
end