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

Support for NullProxy #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alexpeachey
Copy link
Contributor

As requested in Issue #6.

I'm completely open to name changes. I just picked some reasonable names to start with.

It doesn't mention it in Issue #6 but we need some way to get the actual result or , otherwise all you have is the proxy. I chose to go with a method called __object__. I'm not thrilled with this name but I also didn't want to pick something that might exist on the wrapped object. Could go with something like __value__ as well.

I also gave it the option to accept a specific type of null object for the default.

Usage:

require 'naught'

NullProxy([]).first.address.country.__object__    # => <null>
NullProxy([1]).first.abs.__object__               # => 1

null = Naught.build do |config|
  config.define_explicit_conversions
end

NullProxy([], null).first.abs.__object__.to_i     # => 0

@avdi
Copy link
Owner

avdi commented Jul 29, 2014

Thanks Alex! I'll review this when I can.

@sferik sferik force-pushed the master branch 3 times, most recently from 0fa92ab to 4397306 Compare November 10, 2014 15:55
@sferik sferik force-pushed the master branch 4 times, most recently from 1dc5ada to 72228eb Compare September 6, 2015 22:29
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