diff options
author | Santosh Wadghule <santosh.wadghule@gmail.com> | 2016-08-30 19:14:06 +0530 |
---|---|---|
committer | Santosh Wadghule <santosh.wadghule@gmail.com> | 2016-08-31 08:39:11 +0530 |
commit | 547698e8524bac42d4d9011c57a120ac8b5a5fc0 (patch) | |
tree | c4b498deb7cfd1fb86516e8eccd86ba2defec3cd /activerecord/lib | |
parent | 3132fa6b7d9585e04eb44b25b55d298391b040b5 (diff) | |
download | rails-547698e8524bac42d4d9011c57a120ac8b5a5fc0.tar.gz rails-547698e8524bac42d4d9011c57a120ac8b5a5fc0.tar.bz2 rails-547698e8524bac42d4d9011c57a120ac8b5a5fc0.zip |
Refactor remove duplication.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index dc4af4f390..a6615f3774 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -178,7 +178,7 @@ module ActiveRecord # and #destroy returns +false+. # See ActiveRecord::Callbacks for further details. def destroy - raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly? + _raise_readonly_record_error if readonly? destroy_associations self.class.connection.add_transaction_record(self) destroy_row if persisted? @@ -535,7 +535,7 @@ module ActiveRecord end def create_or_update(*args) - raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly? + _raise_readonly_record_error if readonly? result = new_record? ? _create_record : _update_record(*args) result != false end @@ -577,5 +577,9 @@ module ActiveRecord def belongs_to_touch_method :touch end + + def _raise_readonly_record_error + raise ReadOnlyRecord, "#{self.class} is marked as readonly" + end end end |