Class: JsDuck::Process::Ext4Events

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/process/ext4_events.rb

Overview

Appends Ext4 options parameter to the parameter list of each event in each class.

But only does so when :ext4_events option is set to true or the code itself is detected as being writted in Ext4 style.

Constant Summary collapse

OPTIONS =
{
  :tagname => :params,
  :name => "eOpts",
  :type => "Object",
  :doc => "The options object passed to {@link Ext.util.Observable#addListener}.",
  :ext4_auto_param => true,
}

Instance Method Summary collapse

Constructor Details

#initialize(classes, opts = {}) ⇒ Ext4Events

Returns a new instance of Ext4Events.



10
11
12
13
# File 'lib/jsduck/process/ext4_events.rb', line 10

def initialize(classes, opts={})
  @classes = classes
  @opts = opts
end

Instance Method Details

#ext4_style_code?Boolean

Are we dealing with code looking like ExtJS 4? True if any of the classes is defined with Ext.define()

Returns:

  • (Boolean)


23
24
25
# File 'lib/jsduck/process/ext4_events.rb', line 23

def ext4_style_code?
  @classes.values.any? {|cls| cls[:code_type] == :ext_define }
end

#process(cls) ⇒ Object



27
28
29
30
31
# File 'lib/jsduck/process/ext4_events.rb', line 27

def process(cls)
  cls[:members].each do |m|
    m[:params] << OPTIONS if m[:tagname] == :event
  end
end

#process_all!Object



15
16
17
18
19
# File 'lib/jsduck/process/ext4_events.rb', line 15

def process_all!
  if @opts[:ext4_events] == true || (@opts[:ext4_events] == nil && ext4_style_code?)
    @classes.each_value {|cls| process(cls) }
  end
end