Class: Puppeteer::Bidi::LazyArg

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/bidi/lazy_arg.rb,
sig/puppeteer/bidi/lazy_arg.rbs

Overview

LazyArg defers evaluation of expensive arguments (e.g., handles) until serialization time. Mirrors Puppeteer's LazyArg helper.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ LazyArg

Returns a new instance of LazyArg.



15
16
17
# File 'lib/puppeteer/bidi/lazy_arg.rb', line 15

def initialize(&block)
  @block = block
end

Class Method Details

.create(&block) ⇒ void

This method returns an undefined value.

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/puppeteer/bidi/lazy_arg.rb', line 9

def self.create(&block)
  raise ArgumentError, 'LazyArg requires a block' unless block

  new(&block)
end

Instance Method Details

#resolveObject

Returns:

  • (Object)


19
20
21
# File 'lib/puppeteer/bidi/lazy_arg.rb', line 19

def resolve
  @block.call
end