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

Allow builder DSL to accept implicit arrays and hashes #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chrisandreae
Copy link
Member

When a builder DSL method is called with multiple arguments (including the block argument), or keyword arguments, construct the attribute as an array or hash respectively.

Which is invoked after collecting arguments but before delegating to the constructor
@thefloweringash
Copy link

I'm looking for an argument for which cases should be accepted with implicit wrapping and which should be rejected. For the positional+block case the positional argument implicitly gets wrapped in an array, which is to say the overall type is changed to accommodate the block. Should this also apply to maps derived from keyword arguments?

For example:

# Current behavior (IIUC)
x(1)            => 1
x(1) { }        => [1, ->(){}]

# Do these seem consistent?
x(x: :y)                  => { :x => :y }
x(x: :y) {}               => [{ :x => :y }, ->(){}]
x(1, x: :y) { }           => [1, { :x => :y }, ->(){}]
x(1, 2, x: :y, p: :q) { } => [1, 2, { :x => :y, :p => :q }, ->(){}]

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

Successfully merging this pull request may close these issues.

2 participants