Sha256: 6565cbc53e03ca89f5c9f763a8b58bcf28a708ffe2bea421c8caa159a4df8ede

Contents?: true

Size: 721 Bytes

Versions: 10

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

require "factory_bot_rails/definition_file_paths"

module FactoryBotRails
  class Reloader
    def initialize(app)
      @app = app
      @paths = DefinitionFilePaths.new(FactoryBot.definition_file_paths)
    end

    def run
      return unless @paths.any?

      register_reloader(build_reloader)
    end

    private

    attr_reader :app

    def build_reloader
      reloader_class.new(@paths.files, @paths.directories) do
        FactoryBot.reload
      end
    end

    def reloader_class
      app.config.file_watcher
    end

    def register_reloader(reloader)
      app.reloader.to_prepare do
        reloader.execute
      end

      app.reloaders << reloader
    end
  end
end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/factory_bot_rails-6.4.4/lib/factory_bot_rails/reloader.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/factory_bot_rails-6.4.4/lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.4.4 lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.4.3 lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.4.2 lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.4.0 lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.3.0 lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.2.0 lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.1.0 lib/factory_bot_rails/reloader.rb
factory_bot_rails-6.0.0 lib/factory_bot_rails/reloader.rb