From 672f120efc241ba819f3da814fc99efdd99428e5 Mon Sep 17 00:00:00 2001 From: WizardOfOgz Date: Wed, 11 Mar 2015 15:45:01 -0500 Subject: [PATCH] Provide a more ActiveRecord-like interface by aliasing new_record? to new? --- lib/her/model/orm.rb | 1 + spec/model/orm_spec.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lib/her/model/orm.rb b/lib/her/model/orm.rb index fa91b2df..87f46428 100644 --- a/lib/her/model/orm.rb +++ b/lib/her/model/orm.rb @@ -8,6 +8,7 @@ module ORM def new? id.nil? end + alias new_record? new? # Return `true` if a resource is not `#new?` def persisted? diff --git a/spec/model/orm_spec.rb b/spec/model/orm_spec.rb index 5bf523a9..247bfd67 100644 --- a/spec/model/orm_spec.rb +++ b/spec/model/orm_spec.rb @@ -49,10 +49,12 @@ it "handles new resource" do @new_user = Foo::User.new(:fullname => "Tobias Fünke") @new_user.new?.should be_truthy + @new_user.new_record?.should be_truthy @new_user.fullname.should == "Tobias Fünke" @existing_user = Foo::User.find(1) @existing_user.new?.should be_falsey + @existing_user.new_record?.should be_falsey end it 'handles new resource with custom primary key' do