Callable defaults #99

Open
wants to merge 1 commit into
from

Projects

None yet

5 participants

@benburkert

For dynamic defaults.

@kalbasit

I think it would be better to do it like this:

options[key] = value.respond_to?(:call) ? value.call : value

Since both a lambda and a Proc respond to call (plus any other Object the user could create that responds to call as well

@sferik
Member
sferik commented Feb 23, 2013

This seems like a good feature but could you please add tests?

@rweng
rweng commented Jan 7, 2014

+1

@dpehrson

+1 on this. I would like to configure defaults for certain parameters to be read from environment variables (in my case AWS credentials.)

While this works by simply doing :default => ENV['FOO'] it can't be unit tested because by the time tests run, the Thor class is already configured since it was done at load time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment