2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2017-05-02 15:21:13 +00:00
|
|
|
module CanSeed
|
2017-04-27 09:20:57 +00:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
# methods defined here are going to extend the class, not the instance of it
|
|
|
|
class_methods do
|
|
|
|
|
|
|
|
def reseed
|
|
|
|
destroy_all
|
|
|
|
seed
|
|
|
|
end
|
|
|
|
|
|
|
|
def seed
|
|
|
|
UserInfo.ensure_current_user_id do
|
|
|
|
load seedfile
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def seedfile
|
2017-11-23 08:09:44 +00:00
|
|
|
Rails.root.join('db', 'seeds', "#{name.pluralize.underscore.tr('/', '_')}.rb").to_s
|
2017-04-27 09:20:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|