Sha256: 888ec8c615de77c39ddf2c89a5ad619d51d38d1b9cb342c8297543a29f8aa695

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

module Footnotes
  mattr_accessor :before_hooks
  @@before_hooks = []

  mattr_accessor :after_hooks
  @@after_hooks = []

  def self.before(&block)
    @@before_hooks << block
  end

  def self.after(&block)
    @@after_hooks << block
  end

  # The footnotes are applied by default to all actions. You can change this
  # behavior commenting the after_filter line below and putting it in Your
  # application. Then you can cherrypick in which actions it will appear.
  #
  module RailsFootnotesExtension
    def self.included(base)
      base.prepend_before_filter Footnotes::BeforeFilter
      base.after_filter Footnotes::AfterFilter
    end
  end

  def self.run!
    require 'rails-footnotes/footnotes'
    require 'rails-footnotes/backtracer'
    require 'rails-footnotes/abstract_note'
    require 'rails-footnotes/notes/all'

    ActionController::Base.send(:include, RailsFootnotesExtension)

    load Rails.root.join('.rails_footnotes') if Rails.root.join('.rails_footnotes').exist?
    #TODO DEPRECATED
    load Rails.root.join('.footnotes') if Rails.root.join('.footnotes').exist?
  end

  def self.setup
    yield self
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails-footnotes-3.7.8 lib/rails-footnotes.rb
rails-footnotes-3.7.7 lib/rails-footnotes.rb
rails-footnotes-3.7.6 lib/rails-footnotes.rb
rails-footnotes-3.7.5 lib/rails-footnotes.rb
rails-footnotes-3.7.5.rc4 lib/rails-footnotes.rb
rails-footnotes-3.7.5.rc3 lib/rails-footnotes.rb