Sha256: 153478db456015dd33f94c1f84c7505d1eabf85d2d2e1c9b132b58f347b9a3fc

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

require 'active_support/concern'

module Lumber

  # Include this module to add a logger accessible from both class and instance methods.
  # A logger hierarchy will be created if the class including this module is nested
  module PreventRailsOverride
    extend ActiveSupport::Concern

    included do

      class << self
        # Prevent rails from overwriting our logger
        def cattr_reader_with_lumber(*syms)
          without_logger = syms.reject {|s| s == :logger}
          cattr_reader_without_lumber(*without_logger)
        end
        alias_method_chain :cattr_reader, :lumber

        def cattr_writer_with_lumber(*syms)
          without_logger = syms.reject {|s| s == :logger}
          cattr_writer_without_lumber(*without_logger)
        end
        alias_method_chain :cattr_writer, :lumber

        def mattr_reader_with_lumber(*syms)
          without_logger = syms.reject {|s| s == :logger}
          mattr_reader_without_lumber(*without_logger)
        end
        alias_method_chain :mattr_reader, :lumber

        def mattr_writer_with_lumber(*syms)
          without_logger = syms.reject {|s| s == :logger}
          mattr_writer_without_lumber(*without_logger)
        end
        alias_method_chain :mattr_writer, :lumber

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lumber-1.1.3 lib/lumber/prevent_rails_override.rb
lumber-1.1.2 lib/lumber/prevent_rails_override.rb
lumber-1.1.1 lib/lumber/prevent_rails_override.rb