Module: Foobara::Command::Concerns::ShortcutForRun::ClassMethods
- Defined in:
- foobara-0.0.110/projects/command/src/command/concerns/shortcut_for_run.rb
Instance Method Summary collapse
Instance Method Details
#define_command_named_function ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'foobara-0.0.110/projects/command/src/command/concerns/shortcut_for_run.rb', line 21 def define_command_named_function command_class = self convenience_method_name = Foobara::Util.non_full_name(command_class) containing_module = Foobara::Util.module_for(command_class) || Object if containing_module.is_a?(::Class) containing_module.singleton_class.define_method convenience_method_name do |*args, **opts, &block| command_class.run!(*args, **opts, &block) end containing_module.define_method convenience_method_name do |*args, **opts, &block| command_class.run!(*args, **opts, &block) end else containing_module.module_eval do module_function define_method convenience_method_name do |*args, **opts, &block| command_class.run!(*args, **opts, &block) end end end end |
#undefine_command_named_function ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'foobara-0.0.110/projects/command/src/command/concerns/shortcut_for_run.rb', line 45 def undefine_command_named_function command_class = self convenience_method_name = Foobara::Util.non_full_name(command_class) containing_module = Foobara::Util.module_for(command_class) || Object return unless containing_module.respond_to?(convenience_method_name) containing_module.singleton_class.undef_method convenience_method_name if containing_module.is_a?(::Class) containing_module.undef_method convenience_method_name end end |