Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Infer option's type from default value

Unless a class or module is explicitly specified, the option's type will be
determined by the class of the option's default value, if given one.

Closes issue #2.
  • Loading branch information...
commit eccf7dd255ea6d218e182caddef802874fcda565 1 parent 28fa65b
@matheusmoreira authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/acclaim/option.rb
View
6 lib/acclaim/option.rb
@@ -76,8 +76,12 @@ class Option
# @example
# option = Acclaim::Option.new :directory, 'Directory to work in', Pathname, arity: [1, 0], default: Pathname.pwd
def initialize(key, *arguments, &block)
- options = arguments.extract_ribbon!
type = arguments.find { |argument| argument.is_a? Module }
+ options = arguments.extract_ribbon!
+ options.default! do |default|
+ default_type = default.class
+ type ||= default_type if Type.registered? default_type
+ end
strings = arguments.flatten.select do |argument|
argument.is_a? String
Please sign in to comment.
Something went wrong with that request. Please try again.