-
Notifications
You must be signed in to change notification settings - Fork 0
ingoweiss/null_object
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
NullObject ========== Adds a :null_object option to ActiveRecord has_one and belongs_to associations for specifying an object to be returned in place of nil Implements the null object pattern as described in 'Refactoring - Ruby Edition' (Addison-Wesley) Just a very experimental start - use at your own peril. For feedback please contact me at ingo@ingoweiss.com Example ======= user.country = nil user.country.name => 'Missing country' classs User < ActiveRecord::Base belongs_to :country, :null_object => MissingCountry.instance def missing? false end end class MissingCountry def missing? true end def name 'Unknown country' end end Copyright (c) 2008 Ingo Weiss, released under the MIT license
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published