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

Ensure null objects behave correctly with to_a and to_ary #358

Merged
merged 4 commits into from
Jul 11, 2013

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Jul 10, 2013

Further to #357 we could return nil when the double is a as_null_object, we shouldn't change the behaviour when it's not a null object but this could be considered slightly more correct behaviour.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f7caa59 on revisited_bugfix_for_doubles_in_arrays into * on master*.

@alindeman
Copy link
Contributor

Need any help with 1.8.7 here @JonRowe? I have some bandwidth if needed.

@JonRowe
Copy link
Member Author

JonRowe commented Jul 10, 2013

Thanks @alindeman I sussed it, 1.8.7 has a default implementation of to_a which is used regardless of your intent with method_missing, was just not transparent to me last night that what was happening

return 0 if message == :to_int && __mock_proxy.null_object?
if __mock_proxy.null_object?
return 0 if message == :to_int
return nil if [:to_a,:to_ary].include? message
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this look any better as a case statement?

case message
when :to_int
  0
when :to_a, :to_ary
  nil
end

I'm not sure. What do you think?

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3efca73 on revisited_bugfix_for_doubles_in_arrays into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling faa04cf on revisited_bugfix_for_doubles_in_arrays into * on master*.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 71f39f7 on revisited_bugfix_for_doubles_in_arrays into * on master*.

@alindeman
Copy link
Contributor

Looks good to me.

JonRowe added a commit that referenced this pull request Jul 11, 2013
…rays

Ensure null objects behave correctly with to_a and to_ary
@JonRowe JonRowe merged commit 19d39b7 into master Jul 11, 2013
@JonRowe JonRowe deleted the revisited_bugfix_for_doubles_in_arrays branch July 11, 2013 04:46
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.

3 participants