Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Setter in OverwriteOnNil if a :setter is defined #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moses
Copy link

@moses moses commented Dec 28, 2015

I might be misunderstanding the intention of OverwriteOnNil, but it seems like you'd want to use Setter if a :setter is defined for the property.

If I am misunderstanding, please clarify why the supplied test case is invalid. Thanks!

@@ -20,7 +20,13 @@ module Representable
end

OverwriteOnNil = ->(input, options) do
input.nil? ? (SetValue.(input, options); Pipeline::Stop) : input
if input.nil?
function = options[:binding][:setter] ? Setter : SetValue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, but we can't inspect this at runtime for performance reasons, we have to maintain two Override functions and set them at compile time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so rewrite the PR to make the pipeline factory pick which OverwriteOnNil function to use?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly! Thanks! 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants