allow the :converter Proc form composed_of to return nil #6143

Merged
merged 1 commit into from May 21, 2012

Projects

None yet

5 participants

@senny
Ruby on Rails member

This makes it possible to filter invalid input values before they are passed
into the value-object (like empty strings). This behaviour is only relevant
if the :allow_nil options is set to true. Otherwise you will get
the resulting NoMethodError.

This pull-request is the same as #3421 but with the correct merge target.

@senny senny allow the :converter Proc form composed_of to return nil
This makes it possible to filter invalid input values before they are passed
into the value-object (like empty strings). This behaviour is only relevant
if the :allow_nil options is set to true. Otherwise you will get
the resulting NoMethodError.
fa5f037
@senny
Ruby on Rails member

@rafaelfranca here is the new pull-request.

@alup

+1 ... This should be marked with the "ActiveRecord" label.

@thbar

+1

@rafaelfranca
Ruby on Rails member
@thbar

FWIW, our use case here is to support nil with the money gem (which recommends using composed_of).

@senny
Ruby on Rails member

@rafaelfranca any progress on this one?

@rafaelfranca
Ruby on Rails member

I'm not familiar with the Active Record internals. The implementation looks fine to me, but I don't want to get this without talk with @jonleighton or @tenderlove. I'll try to contact they today and give you an answer.

@tenderlove tenderlove merged commit 525839f into rails:master May 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment