Sha256: 26f2e8a85bc945f5cbc52a1e7ea3ff01a38ade9823770c09e5240b8e4dd7d3bc

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module Footnotes
  class Railtie < ::Rails::Railtie

    config.before_configuration do
      if ::Rails.env.development?
        require 'rails-footnotes/footnotes'
        require 'rails-footnotes/backtracer'
        require 'rails-footnotes/view_subscriber'

        # Require each individual note
        notes_glob = File.expand_path("../rails-footnotes/notes/*.rb", __FILE__)
        Dir[notes_glob].each{|note| require note }

        # Subscribe to view events so we can use them later
        ActiveSupport::LogSubscriber.attach_to(:action_view, Footnotes.view_subscriber)

        # The footnotes are applied by default to all actions. To remove the
        # footnotes from an action, use skip_filter in your controller.
        ActionController::Base.prepend_before_filter Footnotes::BeforeFilter
        ActionController::Base.after_filter Footnotes::AfterFilter
      end
    end

    config.to_prepare do
      if ::Rails.env.development?
        # Right so we should reset the events for each request
        Footnotes.view_subscriber.reset!
      end
    end

    # Hook into the logger so we can collect logs
    initializer "rails3-footnotes.hook_logger" do
      if ::Rails.env.development?
        raise ArgumentError, "The logs footnote requires a logger" unless Rails.logger
        Rails.logger.extend LoggingExtensions
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails3-footnotes-4.0.0.pre.10 lib/rails-footnotes.rb