Class: Playwright::ChannelOwner
- Inherits:
-
Object
- Object
- Playwright::ChannelOwner
- Includes:
- EventEmitter
- Defined in:
- lib/playwright/channel_owner.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#_api ⇒ Object
hidden field for caching API instance.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parent, type, guid, initializer) ⇒ ChannelOwner
constructor
A new instance of ChannelOwner.
-
#inspect ⇒ Object
Suppress long long inspect log and avoid RSpec from hanging up…
- #off(event, callback) ⇒ Object
- #on(event, callback) ⇒ Object
- #once(event, callback) ⇒ Object
- #to_s ⇒ Object
Methods included from EventEmitter
Constructor Details
#initialize(parent, type, guid, initializer) ⇒ ChannelOwner
Returns a new instance of ChannelOwner.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/playwright/channel_owner.rb', line 20 def initialize(parent, type, guid, initializer) @objects = {} if parent.is_a?(ChannelOwner) @connection = parent.instance_variable_get(:@connection) @connection.send(:update_object_from_channel_owner, guid, self) @parent = parent @parent.send(:update_object_from_child, guid, self) elsif parent.is_a?(Connection) @connection = parent @connection.send(:update_object_from_channel_owner, guid, self) else raise ArgumentError.new('parent must be an instance of Playwright::ChannelOwner or Playwright::Connection') end @channel = Channel.new(@connection, guid, object: self) @type = type @guid = guid @initializer = initializer @event_to_subscription_mapping = {} after_initialize end |
Instance Attribute Details
#_api ⇒ Object
hidden field for caching API instance.
14 15 16 |
# File 'lib/playwright/channel_owner.rb', line 14 def _api @_api end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
44 45 46 |
# File 'lib/playwright/channel_owner.rb', line 44 def channel @channel end |
Class Method Details
.from(channel) ⇒ Object
5 6 7 |
# File 'lib/playwright/channel_owner.rb', line 5 def self.from(channel) channel.object end |
.from_nullable(channel) ⇒ Object
9 10 11 |
# File 'lib/playwright/channel_owner.rb', line 9 def self.from_nullable(channel) channel&.object end |
Instance Method Details
#inspect ⇒ Object
Suppress long long inspect log and avoid RSpec from hanging up…
104 105 106 |
# File 'lib/playwright/channel_owner.rb', line 104 def inspect to_s end |
#off(event, callback) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/playwright/channel_owner.rb', line 95 def off(event, callback) super if listener_count(event) == 0 update_subscription(event, false) end end |
#on(event, callback) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/playwright/channel_owner.rb', line 79 def on(event, callback) if listener_count(event) == 0 update_subscription(event, true) end super end |
#once(event, callback) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/playwright/channel_owner.rb', line 87 def once(event, callback) if listener_count(event) == 0 update_subscription(event, true) end super end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/playwright/channel_owner.rb', line 108 def to_s "#<#{@guid}>" end |