Sha256: 8cd2aa0f8d9f97ea2941529d3b97cc27cfb9450db48a11dc385e950a75663de0

Contents?: true

Size: 618 Bytes

Versions: 1

Compression:

Stored size: 618 Bytes

Contents

module LogSwitch
  module Mixin

    # When this module is included, this method gets called and defines a +#log+
    # method on the including class.
    #
    # @param [Class] klass The class that's including this module.
    # @raise [RuntimeError] If {LogSwitch.extender} isn't set (which gets set
    #    when you +extend+ your class with {LogSwitch}).
    def self.included(klass)
      if LogSwitch.extender
        klass.send :define_method, :log do |*args|
          LogSwitch.extender.log *args
        end
      else
        raise "No class has been extended by LogSwitch yet."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
log_switch-0.3.0 lib/log_switch/mixin.rb