Sha256: 98afb6aeea53a009e6ded214790cc79ba20fd39f00c4a5c482db16267c2af931

Contents?: true

Size: 1.57 KB

Versions: 9

Compression:

Stored size: 1.57 KB

Contents

require 'rails'
require 'action_controller'
require 'rails-footnotes/abstract_note'
require 'rails-footnotes/each_with_rescue'
require 'rails-footnotes/filter'
require 'rails-footnotes/notes/all'
require 'rails-footnotes/extension'
require 'active_support/deprecation'

module Footnotes
  mattr_accessor :before_hooks
  @@before_hooks = []

  mattr_accessor :after_hooks
  @@after_hooks = []

  mattr_accessor :enabled
  @@enabled = false

  class << self
    delegate :notes, :to => Filter
    delegate :notes=, :to => Filter

    delegate :prefix, :to => Filter
    delegate :prefix=, :to => Filter

    delegate :no_style, :to => Filter
    delegate :no_style=, :to => Filter

    delegate :multiple_notes, :to => Filter
    delegate :multiple_notes=, :to => Filter

    delegate :lock_top_right, :to => Filter
    delegate :lock_top_right=, :to => Filter

    delegate :font_size, :to => Filter
    delegate :font_size=, :to => Filter
  end

  def self.run!
    ActiveSupport::Deprecation.warn "run! is deprecated and will be removed from future releases, use Footnotes.setup or Footnotes.enabled instead.", caller
    Footnotes.enabled = true
  end

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

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

  def self.enabled?
    if @@enabled.is_a? Proc
      @@enabled.call
    else
      !!@@enabled
    end
  end

  def self.setup
    yield self
  end
end

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

load Rails.root.join('.rails_footnotes') if Rails.root && Rails.root.join('.rails_footnotes').exist?

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails-footnotes-4.1.6 lib/rails-footnotes.rb
rails-footnotes-4.1.5 lib/rails-footnotes.rb
rails-footnotes-4.1.4 lib/rails-footnotes.rb
rails-footnotes-4.1.3 lib/rails-footnotes.rb
rails-footnotes-4.1.2 lib/rails-footnotes.rb
rails-footnotes-4.1.1 lib/rails-footnotes.rb
rails-footnotes-4.1.0 lib/rails-footnotes.rb
rails-footnotes-4.0.2 lib/rails-footnotes.rb
rails-footnotes-4.0.1 lib/rails-footnotes.rb