Class: Shoes::LoggedWrapper

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lacci/lib/shoes/log.rb

Constant Summary

Constants included from Log

Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG

Instance Method Summary collapse

Methods included from Log

configure_logger, #log_init, logger

Constructor Details

#initialize(instance, component = instance) ⇒ LoggedWrapper

Returns a new instance of LoggedWrapper.



52
53
54
55
56
# File 'lacci/lib/shoes/log.rb', line 52

def initialize(instance, component = instance)
  log_init(component)

  @instance = instance
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lacci/lib/shoes/log.rb', line 58

def method_missing(method, ...)
  self.singleton_class.define_method(method) do |*args, **kwargs, &block|
    ret = @instance.send(method, *args, **kwargs, &block)
    @log.info("Method: #{method} Args: #{args.inspect} KWargs: #{kwargs.inspect} Block: #{block ? "y" : "n"} Return: #{ret.inspect}")
    ret
  end
  send(method, ...)
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lacci/lib/shoes/log.rb', line 67

def respond_to_missing?(method_name, include_private = false)
  @instance.respond_to_missing?(method_name, include_private)
end