Sha256: 6e01e9a9982659af6e4a2459b721804762c7bed1dcf45786de97f9926ddd31b0

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require "action_texter"
require "rails"
require "abstract_controller/railties/routes_helpers"

module ActionTexter
  class Railtie < Rails::Railtie
    config.action_texter = ActiveSupport::OrderedOptions.new

    initializer "action_texter.logger" do
      ActiveSupport.on_load(:action_texter) { self.logger ||= Rails.logger }
    end

    initializer "action_texter.set_configs" do |app|
      paths   = app.config.paths
      options = app.config.action_texter

      options.assets_dir      ||= paths["public"].first
      options.javascripts_dir ||= paths["public/javascripts"].first
      options.stylesheets_dir ||= paths["public/stylesheets"].first

      # make sure readers methods get compiled
      #options.asset_path          ||= app.config.asset_path
      options.asset_host          ||= app.config.asset_host
      options.relative_url_root   ||= app.config.relative_url_root

      ActiveSupport.on_load(:action_texter) do
        include AbstractController::UrlFor
        extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
        include app.routes.mounted_helpers

        register_interceptors(options.delete(:interceptors))
        register_observers(options.delete(:observers))

        options.each { |k,v| send("#{k}=", v) }
        prepend_view_path(Rails.configuration.paths["app/views"])
      end
    end

    initializer "action_texter.compile_config_methods" do
      ActiveSupport.on_load(:action_texter) do
        config.compile_methods! if config.respond_to?(:compile_methods!)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actiontexter-0.1.0 lib/action_texter/railtie.rb