Skip to content

Commit

Permalink
Merge branch 'hotfix/0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
thornomad committed May 22, 2020
2 parents b8f18c8 + d78790c commit 2cb20fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
enumbler (0.4.1)
enumbler (0.4.2)
activerecord (~> 6.0.2)
activesupport (~> 6.0.2)

Expand Down
10 changes: 6 additions & 4 deletions lib/enumbler/enabler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ def ids_from_enumbler(*args)
# Seeds the database with the Enumbler data.
# @param delete_missing_records [Boolean] remove any records that are no
# longer defined (default: false)
def seed_the_enumbler(delete_missing_records: false)
# @param validate [Boolean] validate on save?
def seed_the_enumbler(delete_missing_records: false, validate: true)
max_database_id = all.order('id desc').take&.id || 0
max_enumble_id = enumbles.map(&:id).max

Expand All @@ -174,16 +175,17 @@ def seed_the_enumbler(delete_missing_records: false)

record = find_or_initialize_by(id: id)
record.attributes = enumble.attributes
record.save!
record.save!(validate: validate)
end

where(id: discarded_ids).delete_all if delete_missing_records
end

# Seeds the database with the Enumble data, removing any records that are no
# longer defined.
def seed_the_enumbler!
seed_the_enumbler(delete_missing_records: true)
# @param validate [Boolean] validate on save?
def seed_the_enumbler!(validate: true)
seed_the_enumbler(delete_missing_records: true, validate: validate)
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/enumbler/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Enumbler
VERSION = '0.4.1'
VERSION = '0.4.2'
end

0 comments on commit 2cb20fb

Please sign in to comment.