barsoom / attr_extras

Takes some boilerplate out of Ruby with methods like attr_initialize.
MIT License
560 stars 31 forks source link

Fix ivars with default arguments for using with readers #29

Closed roman-dubrovsky closed 5 years ago

roman-dubrovsky commented 5 years ago

This PR fixes issue with using keyword arguments with default values in pattr_initialize (as well as rattr_initialize and other) method. (described this bug here https://github.com/barsoom/attr_extras/pull/28)

The main issue is that Utils::flat_names doesn't process correctly case when we pass hash in the names list with arguments. As a result, we get something like this

> AttrExtras::Utils.flat_names(:foo, [bar: "Bar", baz!: "Bar"])
["foo", "{:bar=>\"Bar\", :baz!=>\"Bar\"}"]
henrik commented 5 years ago

Thank you so much! Well caught. I have a few "lab days" at work right now, so I hope to look at and merge this Friday at the latest. Please nag me if I haven't :)

henrik commented 5 years ago

Didn't get around to it :( Had too much shiny stuff to play with. I'll try to squeeze it in Monday!

henrik commented 5 years ago

Merged and released. Thank you so much, @roman-dubrovsky! Sorry for the delay.

roman-dubrovsky commented 5 years ago

np, thank you for this library 😉