Class: LazyObject Private
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
An object which lazily evaluates its inner block only once a method is called on it.
Instance Method Summary collapse
-
#__getobj__ ⇒ Object
private
-
#__setobj__(callable) ⇒ Object
private
-
#initialize(&callable) ⇒ LazyObject
constructor
private
A new instance of LazyObject.
-
#is_a?(klass) ⇒ Boolean
private
Forward to the inner object to make lazy objects type-checkable.
Constructor Details
#initialize(&callable) ⇒ LazyObject
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a new instance of LazyObject.
8 9 10 |
# File 'lazy_object.rb', line 8 def initialize(&callable) super(callable) end |
Instance Method Details
#__getobj__ ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
12 13 14 15 16 17 18 |
# File 'lazy_object.rb', line 12 def __getobj__ # rubocop:disable Naming/MemoizedInstanceVariableName return @__delegate__ if defined?(@__delegate__) @__delegate__ = @__callable__.call # rubocop:enable Naming/MemoizedInstanceVariableName end |
#__setobj__(callable) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
20 21 22 |
# File 'lazy_object.rb', line 20 def __setobj__(callable) @__callable__ = callable end |
#is_a?(klass) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Forward to the inner object to make lazy objects type-checkable.
25 26 27 |
# File 'lazy_object.rb', line 25 def is_a?(klass) __getobj__.is_a?(klass) || super end |