sanger/record_loader

View on GitHub
lib/generators/record_loader/templates/lib/record_loader/%underscore_loader%.rb.tt

Summary

Maintainability
Test Coverage
# frozen_string_literal: true

# This file was automatically generated via `rails g record_loader`

# RecordLoader handles automatic population and updating of database records
# across different environments
# @see https://rubydoc.info/github/sanger/record_loader/
module RecordLoader
  # Creates the specified <%= record_class %> if they are not present
  class <%= loader_class_name %> < ApplicationRecordLoader
    config_folder '<%= underscores %>'

    def create_or_update!(<%= record_key %>, options)
      <%= record_class %>.create_with(options).find_or_create_by!(<%= record_key %>: <%= record_key %>)
    end
  end
end