Closed danielvidal closed 6 years ago
Greetings!
I figured out a bug that changes the custom type after the method attributes is called from the model.
attributes
Remember these classes...
class Address include ShallowAttributes attribute :street, String end class Person include ShallowAttributes attribute :address, Address end
Current behavior:
person = Person.new(address: { street: 'Street 1/2' }) person.address.class # => Address person.address # => #<Address street="Street 1/2"> person.attributes # => { address: { street: "Street 1/2" } } person.address.class # => Hash person.address # => { street: "Street 1/2" }
After fix behavior:
person = Person.new(address: { street: 'Street 1/2' }) person.address.class # => Address person.address # => #<Address street="Street 1/2"> person.attributes # => { address: { street: "Street 1/2" } } person.address.class # => Address person.address # => #<Address street="Street 1/2">
I think this is the expected behavior π Any comments about the changes and/or code implementation are welcome
Coverage increased (+52.8%) to 99.879% when pulling d8e644069f9eeb79ba8466a0a851e01e62c3f3a8 on danielvidal:bugfix-custom-type-changed into 754d238009b8068d0268f54cb5acc53377e4d03e on davydovanton:master.
Hi β any chance you could release a new version with this fix in it? Thanks!
hey, new version is here π https://rubygems.org/gems/shallow_attributes/versions/0.9.4
@davydovanton β thank you!
Greetings!
I figured out a bug that changes the custom type after the method
attributes
is called from the model.Remember these classes...
Current behavior:
After fix behavior:
I think this is the expected behavior π Any comments about the changes and/or code implementation are welcome