Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use Kernel methods in a Configuration block #3

Open
mfischer-zd opened this issue Jan 9, 2016 · 2 comments
Open

Can't use Kernel methods in a Configuration block #3

mfischer-zd opened this issue Jan 9, 2016 · 2 comments
Assignees

Comments

@mfischer-zd
Copy link

Unadorned methods like catch and throw can't currently be used in a Configuration block without causing load errors.

 credentials do
    provider :aws

    catch(:done) do
      [ENV['AWS_CREDENTIALS_PATH'], File.expand_path("~/.aws/config"), File.expand_path('~/.aws/credentials')].each do |file|
        if File.exist?(file.to_s)
          aws_profile_name ENV['AWS_PROFILE'] || 'tokyo'
          aws_credentials_file file
          throw(:done)
        end
      end
   end

One fully-qualify the methods (e.g. ::Kernel.catch) to avoid errors, but this is a pretty baroque workaround, especially for non-skilled Ruby programmers who are used to DSLs like Chef recipes working without them.

@chrisroberts
Copy link
Member

Hi! This is expected behavior of the DSL and I won't be changing this default behavior. One thing that I have on my todo list is adding an option when initializing an attribute struct object to optionally load root namespace constants (chrisroberts/attribute_struct#5). Batali is doing this within a customized struct it uses for parsing a Batali file and I'm looking to extract it to attribute_struct so it can be easily opted into else where. Once that's done, I'll add opt-in ability to the configuration struct.

Cheers!

@mfischer-zd
Copy link
Author

Have you considered usability when determining what the "expected behavior" should be? I think I have a strong argument.

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

No branches or pull requests

2 participants