Module: Commander::Patches::OptionDefaults
- Included in:
- Command
- Defined in:
- lib/commander/patches/option_defaults.rb
Instance Method Summary collapse
-
#option(*args, &block) ⇒ Object
I can’t remember what this patch does, but I found it in the code base.
Instance Method Details
#option(*args, &block) ⇒ Object
I can’t remember what this patch does, but I found it in the code base. It is better if this magic is kept separate
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/commander/patches/option_defaults.rb', line 6 def option(*args, &block) default = nil args.delete_if do |v| if v.is_a?(Hash) && v.key?(:default) default = v[:default] true else false end end opt = super opt.tap do |h| h.merge!( { default: default } ) unless default.nil? end end |