Sha256: a447757c5b06f9b7b6ecd836e53a29eed9e41832a5ce022bc68ef49773bb5a4f

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

require 'shirinji'

module ShirinjiRails
  class Railtie < Rails::Railtie
    config.shirinji = ActiveSupport::OrderedOptions.new

    config.shirinji.config_path = nil

    initializer 'shirinji-rails.load_config' do
      init!
    end

    def init!
      return unless (conf = config_path)

      map = Shirinji::Map.load(conf)
      resolver = Shirinji::Resolver.new(map)

      ActiveSupport::Reloader.to_prepare do
        map = Shirinji::Map.load(conf)
        resolver.reload(map)
      end

      config.shirinji.resolver = resolver
    end

    private

    def config_path
      ::Rails.application.config.shirinji.config_path ||
      ::Rails.root.join('config/dependencies.rb')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shirinji-rails-0.0.5 lib/shirinji-rails/railtie.rb