Class: Browser::Event::Custom

Inherits:
Browser::Event show all
Defined in:
opal/browser/event/custom.rb

Defined Under Namespace

Classes: Definition

Instance Attribute Summary

Attributes inherited from Browser::Event

#callback, #on

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Browser::Event

aliases, #arguments, #arguments=, class_for, create, #name, name_for, new, #off, #prevent, #prevented?, #stop, #stop!, #stopped?, #target

Constructor Details

#initialize(event, callback = nil) ⇒ Custom

Returns a new instance of Custom.



52
53
54
55
56
# File 'opal/browser/event/custom.rb', line 52

def initialize(event, callback = nil)
  super(event, callback)

  @detail = Hash.new(`#{event}.detail`)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id) ⇒ Object



58
59
60
61
62
# File 'opal/browser/event/custom.rb', line 58

def method_missing(id, *)
  return @detail[id] if @detail.has_key?(id)

  super
end

Class Method Details

.construct(name, desc) ⇒ Object



19
20
21
22
23
24
# File 'opal/browser/event/custom.rb', line 19

def self.construct(name, desc)
  `new CustomEvent(name, {
    bubbles:    desc.bubbles,
    cancelable: desc.cancelable,
    detail:     desc })`
end

.supported?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'opal/browser/event/custom.rb', line 6

def self.supported?
  Browser.supports? 'Event.Custom'
end