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 defaults with lambdas of arity 0 to be overriden #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jcmfernandes
Copy link

Hi Rodrigo! 👋

Let me start by thanking you for your work on the "micro" family of gems. Great stuff!

I stumped across this bug earlier today. I couldn't override a default when playing around with u-case, and I had to understand why. Here is why.

As a more general remark, the default optional seems somewhat overloaded. Maybe we could move the value preprocessing behavior to a different option. What do you think? It would be a breaking change.

Obrigado! 🏆

@jweslley
Copy link

jweslley commented Jun 22, 2022

@serradura I agree with the changes in this PR. I started using u-attrs recently and I didn't expect the actual behavior. I'm not able to override the default value when passing the attribute to initialize.

For now, I'm using attribute :name, default: -> name { name || 'default value' } as a workaround, but it is more verbose than just attribute :name, default: -> { 'default value' }

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