Skip to content

Instantly share code, notes, and snippets.

@sergeykish
Created August 5, 2010 08:40
Show Gist options
  • Select an option

  • Save sergeykish/509441 to your computer and use it in GitHub Desktop.

Select an option

Save sergeykish/509441 to your computer and use it in GitHub Desktop.
ruby default
class Object
def default(value)
self
end
end
class NilClass
def default(value)
value
end
end
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