lib/thor/invocation.rb in thor-0.19.1 vs lib/thor/invocation.rb in thor-0.19.2
- old
+ new
@@ -106,12 +106,12 @@
args.unshift(nil) if args.first.is_a?(Array) || args.first.nil?
command, args, opts, config = args
klass, command = _retrieve_class_and_command(name, command)
- fail "Missing Thor class for invoke #{name}" unless klass
- fail "Expected Thor class, got #{klass}" unless klass <= Thor::Base
+ raise "Missing Thor class for invoke #{name}" unless klass
+ raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base
args, opts, config = _parse_initialization_options(args, opts, config)
klass.send(:dispatch, command, args, opts, config) do |instance|
instance.parent_options = options
end
@@ -148,13 +148,12 @@
# This method simply retrieves the class and command to be invoked.
# If the name is nil or the given name is a command in the current class,
# use the given name and return self as class. Otherwise, call
# prepare_for_invocation in the current class.
def _retrieve_class_and_command(name, sent_command = nil) #:nodoc:
- case
- when name.nil?
+ if name.nil?
[self.class, nil]
- when self.class.all_commands[name.to_s]
+ elsif self.class.all_commands[name.to_s]
[self.class, name.to_s]
else
klass, command = self.class.prepare_for_invocation(nil, name)
[klass, command || sent_command]
end