Sha256: bf6b09f161918411fe5b6412379a626f606e6dfb9898f5d0e308be5716ee324f

Contents?: true

Size: 798 Bytes

Versions: 2

Compression:

Stored size: 798 Bytes

Contents

module RouteDog
  class Railtie < Rails::Railtie

    rake_tasks do
      load "tasks/tasks.rake"
    end

    initializer "route_dog.configure_rails_initialization" do |app|
      setup_middlewares(app)
    end

  private

    def setup_middlewares(app)
      if route_dog_configuration.fetch("watcher", {}).fetch("env", []).include?(Rails.env)
        app.config.middleware.use RouteDog::Middleware::Watcher
      end

      if route_dog_configuration.fetch("notifier", {}).fetch("env", []).include?(Rails.env)
        app.config.middleware.use RouteDog::Middleware::Notifier
      end
    end

    def route_dog_configuration
      YAML.load_file(RouteDog.config_file)
    rescue Errno::ENOENT
      {"watcher" => {"env" => ["test"]}, "notifier" => {"env" => ["development"]}}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
route_dog-2.5.1 lib/route_dog/railtie.rb
route_dog-2.5.0 lib/route_dog/railtie.rb