Created
August 5, 2010 08:40
-
-
Save sergeykish/509441 to your computer and use it in GitHub Desktop.
ruby default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Object | |
| def default(value) | |
| self | |
| end | |
| end | |
| class NilClass | |
| def default(value) | |
| value | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'default' | |
| describe 'Default' do | |
| it "returns origin value if available" do | |
| 'origin'.default('default').should == 'origin' | |
| end | |
| it "returns delaut value unless origin available" do | |
| nil.default('default').should == 'default' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment