module Servizio::Service::MethodDecorators
This code does some metaprogramming magic. It overwrites .new, so that every instance of a class derived from Servizio::Service
, gets a module prepended automatically. This way, one can easily “wrap” the methods, e.g. call.
Public Class Methods
inherited(subsubclass)
click to toggle source
# File lib/servizio/service.rb, line 92 def self.inherited(subsubclass) subsubclass.extend(Servizio::Service::MethodDecorators) end
new(*args, &block)
click to toggle source
# File lib/servizio/service.rb, line 96 def self.new(*args, &block) (obj = original_new(*args, &block)).singleton_class.send(:prepend, Servizio::Service::MethodDecorators::Call) return obj end
Public Instance Methods
inherited(subclass)
click to toggle source
# File lib/servizio/service.rb, line 88 def inherited(subclass) subclass.instance_eval do alias :original_new :new def self.inherited(subsubclass) subsubclass.extend(Servizio::Service::MethodDecorators) end def self.new(*args, &block) (obj = original_new(*args, &block)).singleton_class.send(:prepend, Servizio::Service::MethodDecorators::Call) return obj end end end