literal icon indicating copy to clipboard operation
literal copied to clipboard

Switch to `prop` instead of `attribute`

Open joeldrapper opened this issue 1 year ago • 3 comments

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.

joeldrapper avatar Apr 25 '24 00:04 joeldrapper

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.

hangsu avatar Apr 25 '24 01:04 hangsu

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.

joelmoss avatar Apr 26 '24 08:04 joelmoss

I think we would need to consider block (:&), kwargs (:**) and rest (:*) as well.

If anything, I would've expected :positional rather than positional: true

hangsu avatar Apr 26 '24 15:04 hangsu

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.

joeldrapper avatar Jun 23 '24 11:06 joeldrapper