literal
literal copied to clipboard
Switch to `prop` instead of `attribute`
The attribute macro is defined on Active Model and various other gems. I think we should consider using a different name. The best I’ve been able to come up with is prop, short for property — and Literal::Attributes could be renamed Literal::Properties.
I’d appreciate hearing any thoughts on this.
We've never run into any problems with attribute at Clearscope, but that might be because we've never had the urge to mix Literal::Attributes with anything ActiveRecord or ActiveModel-related.
I wouldn't be bothered about the renaming though.
I do sometimes get confused by Literal::Data and Literal::Struct both using attribute since the behavior feels fundamentally different than Literal::Attribute (public reader/writers vs no reader/writers by default). Feels like they deserve a different macro name and interface.
I kinda like the naming that dry-initializer uses; that being param for positional args, and option for keyword args. I particularly like that the two types of argument are differentiated, which makes it clearer than using the positional kwarg in literal.
I think we would need to consider block (:&), kwargs (:**) and rest (:*) as well.
If anything, I would've expected :positional rather than positional: true
I’d rather not use different keywords for all these different types of property. @hangsu, I love the suggestion to pass :positional in the same place that you’d pass :&, etc.