class Playwright::PlaywrightApi

Public Class Methods

new(impl) click to toggle source

@param impl [Playwright::ChannelOwner|Playwright::ApiImplementation]

# File lib/playwright/playwright_api.rb, line 111
def initialize(impl)
  @impl = impl
end
unwrap(api) click to toggle source

Unwrap ChannelOwner / ApiImplementation. @note Intended for internal use only.

# File lib/playwright/playwright_api.rb, line 23
def self.unwrap(api)
  case api
  when PlaywrightApi
    api.instance_variable_get(:@impl)
  else
    api
  end
end
wrap(channel_owner_or_api_implementation) click to toggle source

Wrap ChannelOwner / ApiImplementation. Playwright::ChannelOwners::XXXXX will be wrapped as Playwright::XXXXX Playwright::YYYYImpl will be wrapped as Playwright::YYYY Playwright::XXXXX is automatically generated by development/generate_api

@param channel_owner [ChannelOwner|ApiImplementation] @note Intended for internal use only.

# File lib/playwright/playwright_api.rb, line 10
def self.wrap(channel_owner_or_api_implementation)
  case channel_owner_or_api_implementation
  when ChannelOwner
    ChannelOwnerWrapper.new(channel_owner_or_api_implementation).wrap
  when ApiImplementation
    ApiImplementationWrapper.new(channel_owner_or_api_implementation).wrap
  else
    channel_owner_or_api_implementation
  end
end

Private Instance Methods

unwrap_impl(object) click to toggle source
# File lib/playwright/playwright_api.rb, line 135
        def unwrap_impl(object)
  if object.is_a?(Array)
    object.map { |obj| unwrap_impl(obj) }
  elsif object.is_a?(Hash)
    object.map { |key, obj| [key, unwrap_impl(obj)] }.to_h
  elsif object.is_a?(PlaywrightApi)
    ::Playwright::PlaywrightApi.unwrap(object)
  else
    object
  end
end
wrap_block_call(block) click to toggle source

@param block [Proc]

# File lib/playwright/playwright_api.rb, line 116
        def wrap_block_call(block)
  return nil unless block.is_a?(Proc)

  -> (*args) {
    wrapped_args = args.map { |arg| wrap_impl(arg) }
    block.call(*wrapped_args)
  }
end
wrap_impl(object) click to toggle source
# File lib/playwright/playwright_api.rb, line 125
        def wrap_impl(object)
  if object.is_a?(Array)
    object.map { |obj| wrap_impl(obj) }
  elsif object.is_a?(Hash)
    object.map { |key, obj| [key, wrap_impl(obj)] }.to_h
  else
    ::Playwright::PlaywrightApi.wrap(object)
  end
end