class TextEditor::Command::Resolver

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
   # File lib/text_editor/command/resolver.rb
 6 def method_missing(method, *args, &block)
 7   command = resolve(method)
 8   return super unless command
 9   command.call(editor, *args, &block)
10   self
11 end
resolve(method) click to toggle source
   # File lib/text_editor/command/resolver.rb
13 def resolve(method)
14   return method if method.respond_to?(:call)
15   parts = method.to_s.split("_")
16   name = parts.map(&:capitalize).join
17   command(name)
18 end

Private Instance Methods

command(name) click to toggle source
   # File lib/text_editor/command/resolver.rb
22 def command(name)
23   namespace.const_get(name)
24 rescue NameError
25   nil
26 end
namespace() click to toggle source
   # File lib/text_editor/command/resolver.rb
28 def namespace
29   Module.nesting[1]
30 end
respond_to_missing?(method, include_super) click to toggle source
Calls superclass method
   # File lib/text_editor/command/resolver.rb
32 def respond_to_missing?(method, include_super)
33   resolve(method) || super
34 end