Sha256: 0ca67b976cdd20a7789113ae2bf83614699af9b30db62649216e59d53fbb67d3

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Sail
  class Engine < ::Rails::Engine
    isolate_namespace Sail

    config.generators do |g|
      g.test_framework :rspec
    end

    initializer 'sail' do
      unless Sail.configuration.dashboard_auth_lambda.nil?
        to_prepare do
          Sail::SettingsController.before_action(*Sail.configuration.dashboard_auth_lambda)
        end
      end
    end

    config.after_initialize do
      if File.exist?("#{Rails.root}/config/sail.yml")
        YAML.load_file("#{Rails.root}/config/sail.yml").each do |name, attrs|
          string_attrs = attrs.merge(name: name)
          string_attrs.update(string_attrs) { |_, v| v.to_s }
          Sail::Setting.where(name: name).first_or_create(string_attrs)
        end
      end
    end

    private

    def to_prepare
      klass = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader
      klass.to_prepare(&Proc.new)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sail-1.4.2 lib/sail/engine.rb
sail-1.4.1 lib/sail/engine.rb