lib/rake-commander/option.rb in rake-commander-0.2.11 vs lib/rake-commander/option.rb in rake-commander-0.2.12
- old
+ new
@@ -90,11 +90,13 @@
self.class.argument_required?(argument)
end
# @return [Class, NilClass]
def type_coercion
- @type_coercion || (default? && default.class)
+ value = @type_coercion || (default? && default.class)
+ return nil unless value.is_a?(Class)
+ value
end
# @return [Boolean]
def default?
instance_variable_defined?(:@default)
@@ -228,17 +230,17 @@
end
end
# It consumes `other_args`, to prevent direct overrides to be overriden by it.
def configure_other
- @type_coertion ||= fetch_type_from_other
+ @type_coercion ||= fetch_type_from_other
@desc ||= fetch_desc_from_other
nil
end
def fetch_type_from_other
return nil unless type = other_args.find {|arg| arg.is_a?(Class)}
- other_args.delete(type)
+ type.tap { other_args.delete(type) }
end
def fetch_desc_from_other
return nil unless value = other_args.find {|arg| arg.is_a?(String)}
other_args.dup.each do |val|