Skip to content

Commit

Permalink
Merge #14 'fix_issue_with_changed_attributes_for_rails_5'
Browse files Browse the repository at this point in the history
* Bump to 0.7.1
* remotes/origin/fix_issue_with_changed_attributes_for_rails_5:
  Allow any version of rails 5
  Updated logic to handle changed attributes properly for rails 5.2.
  • Loading branch information
zbelzer committed Aug 7, 2020
2 parents d9a37cb + 0e5e641 commit 080c2ad
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion HornsAndHooves-moribus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]

# specify any dependencies here; for example:
s.add_dependency "rails", "~> 5.0"
s.add_dependency "rails", "~> 5"
s.add_dependency "power_enum", ">= 2.7.0"
s.add_dependency "yard", ">= 0"

Expand Down
7 changes: 2 additions & 5 deletions lib/moribus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def to_persistent!(existing = nil)
self.id = existing.id
self.created_at = existing.created_at if respond_to?(:created_at)
self.updated_at = existing.updated_at if respond_to?(:updated_at)
@changed_attributes = {}

clear_changes_information
else
restore_before_to_new_record_values
end
Expand Down Expand Up @@ -145,14 +146,10 @@ def reset_persistence_values

if respond_to?(:updated_at=)
self.updated_at = nil
@changed_attributes =
ActiveSupport::HashWithIndifferentAccess.new(changed_attributes.dup.merge(updated_at: nil))
end

if respond_to?(:created_at=)
self.created_at = nil
@changed_attributes =
ActiveSupport::HashWithIndifferentAccess.new(changed_attributes.dup.merge(created_at: nil))
end

# mark all other attributes is changing
Expand Down
2 changes: 1 addition & 1 deletion lib/moribus/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Moribus # :nodoc:
VERSION = "0.7.0" # :nodoc:
VERSION = "0.7.1" # :nodoc:
end

0 comments on commit 080c2ad

Please sign in to comment.