Class: WebTools::MethodList

Inherits:
Tool
  • Object
show all
Defined in:
lib/web_tools/method_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tool

display_name, dont_show!, dont_show?, file_name, inherited, subclasses

Methods included from Support::ServiceHelper

included

Class Method Details

.descriptionObject



8
9
10
# File 'lib/web_tools/method_list.rb', line 8

def self.description
  super
end

Instance Method Details

#execute(meth) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/web_tools/method_list.rb', line 16

def execute(meth)
  callables = { "method" => method(:find_method),
    "implementors" => method(:implementors),
    "senders" => method(:senders),
    "referencesToGlobal" => method(:references_to_global) }
  callable = callables[meth]
  return {"a" => "AAA"} if callable.nil?
  callable[]
end

#find_methodObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/web_tools/method_list.rb', line 26

def find_method
  name = non_meta_name(params["klass"])
  is_meta = !(name == params["klass"])
  klass = reflect(Object).constant(name).value
  klass = klass.singleton_class if is_meta
  meth = klass.method(params["selector"])
  { "dictionaryName" => params["dict"],
    "className" => klass.name,
    "isMeta" => is_meta,
    "source" => meth.source,
    "stepPoints" => meth.step_offsets,
    "sends" => meth.send_offsets }
end

#implementorsObject



40
41
42
43
# File 'lib/web_tools/method_list.rb', line 40

def implementors
  return {} unless params["find"]
  methods(system.implementations_of(params["find"]))
end

#methods(list) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/web_tools/method_list.rb', line 54

def methods(list)
  list = list.collect do |meth|
    klass = meth.defining_class
    nesting = klass.nesting
    dict = nesting[1] ? nesting[1].name : "" # [klass, parent, ...]
    { "dict" => dict,
      "klassCat" => "",
      "klass" => klass.name,
      "category" => "",
      "selector" => meth.selector }
  end
  { "list" => list }
end

#references_to_globalObject



50
51
52
# File 'lib/web_tools/method_list.rb', line 50

def references_to_global
  return {} # Not supported on Ruby, too dynamic
end

#sendersObject



45
46
47
48
# File 'lib/web_tools/method_list.rb', line 45

def senders
  return {} unless params["find"]
  methods(system.senders_of(params["find"]))
end