def as(method, &block)
      raise ArgumentError, 'Missing mandatory block' unless block_given?

      method  = method.to_sym

      # Define the guard at class-level, if not already defined.
      if !eigenclass.respond_to?(method)
        eigenclass.send(:define_method, method) do |*args|
          Render.new.instance_exec(*args, &block)
        end
      end

      # Define the guard at instance-level by overriding #initialize, if not
      # already defined.
      eigenclass.send(:define_method, :new) do
        o = super
        if !o.respond_to?(method)
          o.send(:define_method, method) do |*args|
            Render.new.instance_exec(*args, &block)
          end
        end
        o
      end
    end
def as(method, &block)
      raise ArgumentError, 'Missing mandatory block' unless block_given?

      method  = method.to_sym

      # Define the guard at class-level, if not already defined.
      if !eigenclass.respond_to?(method)
        eigenclass.send(:define_method, method) do |*args|
          Render.new.instance_exec(*args, &block)
        end
      end

      # Define the guard at instance-level by overriding #initialize, if not
      # already defined.
      eigenclass.send(:define_method, :new) do
        o = super
        if !o.respond_to?(method)
          o.send(:define_method, method) do |*args|
            Render.new.instance_exec(*args, &block)
          end
        end
        o
      end
    end
Define a custom logger, using a template. The template may be defined
 within the block as a (multi-line) string, or one may reference a
 file.
     # do whatever you want with data or anything else, for instance,
     send mails, tweet, then…

 Inline templates (defined within the block) make use of #render_inline
 (indentation broken for the sake of example readibility):

   logger.as(:custom) do |response|
     tpl = <<-TPL
       %h2 Query log report
       %span
         Statu:
         = data.status
       %span
         Response:
         = data.body
       %br/
     TPL
     puts render_inline(tpl, :as => :haml, :data => response)
   end

 With an external template, one should use the #render helper to, well,
 render the template file. The extension will be used to infer the proper
 rendering engine. If not provided or when a custom extension is used, one
 may declare the template syntax.

   logger.as(:custom) do |data|
     # do whatever you want with data or anything else, then…
     out = render('my/template.erb', :data => data)
     # one may then use out to send mails, log to file, tweet…
   end

   logger.as(:custom) do |data|
     render('my/template', :as => :erb, :data => data)
   end

 See #render and #render_inline for more details.

 TODO: memoize the Render instance somehow? Or find another trick to
 execute the block.