Module: Ing::Boot
- Included in:
- Commands::Generate, Commands::Implicit
- Defined in:
- lib/ing/boot.rb
Overview
Base implementation of boot dispatch Mixed in to Commands::Implicit, Commands::Generate Note this does NOT provide any options, only provides implementation. Assumes target class will provide namespace option, otherwise defaults to global namespace (::Object).
Instance Method Summary collapse
-
#call(*args) ⇒ Object
- Main processing of arguments and dispatch from command line (
Ing.run) Note that three hooks are provided for target classes,before - runs before any processing of arguments or dispatch of command
configure_command - configures the command prior to dispatch
after -
runs after command dispatched.
- configures the command prior to dispatch
- runs before any processing of arguments or dispatch of command
- Main processing of arguments and dispatch from command line (
-
#call_execute(klass, meth, *args) ⇒ Object
Dispatch from
Ing.execute. -
#call_invoke(klass, meth, *args) ⇒ Object
Dispatch from
Ing.invoke. -
#configure_command(cmd) ⇒ Object
Configure the command prior to dispatch.
Instance Method Details
#call(*args) ⇒ Object
Main processing of arguments and dispatch from command line (Ing.run) Note that three hooks are provided for target classes,
+before+:: runs before any processing of arguments or dispatch of command
+configure_command+:: configures the command prior to dispatch
+after+:: runs after command dispatched
25 26 27 28 29 30 31 32 33 |
# File 'lib/ing/boot.rb', line 25 def call(*args) before *args if respond_to?(:before) ns = Ing::Util.to_class_names([:namespace] || 'object') classes = Ing::Util.to_class_names(args.shift) Dispatcher.new(ns, classes, *args).dispatch do |cmd| configure_command cmd end after if respond_to?(:after) end |
#call_execute(klass, meth, *args) ⇒ Object
Dispatch from Ing.execute
45 46 47 48 49 50 51 |
# File 'lib/ing/boot.rb', line 45 def call_execute(klass, meth, *args) before *args if respond_to?(:before) Dispatcher.execute(klass, meth, *args) do |cmd| configure_command cmd end after if respond_to?(:after) end |
#call_invoke(klass, meth, *args) ⇒ Object
Dispatch from Ing.invoke
36 37 38 39 40 41 42 |
# File 'lib/ing/boot.rb', line 36 def call_invoke(klass, meth, *args) before *args if respond_to?(:before) Dispatcher.invoke(klass, meth, *args) do |cmd| configure_command cmd end after if respond_to?(:after) end |
#configure_command(cmd) ⇒ Object
Configure the command prior to dispatch. Default behavior is to set the shell of the dispatched command. Override in target class as needed; if you want to keep the default behavior then call super.
15 16 17 |
# File 'lib/ing/boot.rb', line 15 def configure_command(cmd) cmd.shell = Ing.shell_class.new if cmd.respond_to?(:"shell=") end |