Module: Xrc::MethodLoggable

Defined in:
lib/xrc/method_loggable.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.loggerObject



9
10
11
# File 'lib/xrc/method_loggable.rb', line 9

def logger
  @logger ||= ActiveSupport::Logger.new(STDOUT)
end

Instance Method Details

#log(method_name, &block) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/xrc/method_loggable.rb', line 14

def log(method_name, &block)
  define_method("#{method_name}_with_log") do |*args|
    Xrc::MethodLoggable.logger.info(instance_exec(*args, &block))
    __send__("#{method_name}_without_log", *args)
  end
  alias_method_chain method_name, :log
end