class Carioca::Services::ProxyDebug

Service Debug of Carioca Proxy Class Debug for devs

Public Class Methods

new(_options) click to toggle source

ProxyDebug service constructor (has a class proxy => so a service proxy) @param [Hash] _options the params @option _options [String] :service the name of the service you want to proxyfying @option _options [Hash] :params the params of the proxyfied service

# File lib/carioca/services/debug.rb, line 31
def initialize(_options)
  options = Methodic.get_options(_options)
  options.specify_classes_of :service => String
  options.specify_presence_of([:service])
  options.validate!
  if options[:params] then
    @obj = Registry.init.start_service :name  => options[:service], :params => options[:params]
  else
    @obj = Registry.init.start_service :name  => options[:service]
  end
  @log  = Registry.init.get_service :name => 'logger'
  @mapped_service = options[:service]
end

Public Instance Methods

method_missing(methodname, *args,&block) click to toggle source

method_missing overload to make the class proxy efficient

# File lib/carioca/services/debug.rb, line 46
def method_missing(methodname, *args,&block)
  @log.debug("ProxyDebug") { "BEGIN CALL for mapped service #{@mapped_service} "}
  @log.debug("ProxyDebug") { "called: #{methodname} " }
  @log.debug("ProxyDebug") { "args : #{args.join " "}" }
  if block_given? then
    @log.debug("ProxyDebug") { "block given" }
    a = @obj.send(methodname, *args,&block)
  else
    a = @obj.send(methodname, *args)
  end
  @log.debug("ProxyDebug") { "=> returned: #{a} " }
  @log.debug("ProxyDebug") { 'END CALL' }
  return a
end