class Protobuf::Rpc::Service
def method_added(old)
We want to remap the method such that we can wrap it in before and after behavior,
or it isn't in the reserved method list (NON_RPC_METHODS),
If the method isn't already a private instance method, or it doesn't start with rpc_,
Override methods being added to the class
def method_added(old) new_method = :"rpc_#{old}" return if private_instance_methods.include?(new_method) or old =~ /^rpc_/ or NON_RPC_METHODS.include?(old.to_s) alias_method new_method, old private new_method define_method(old) do |pb_request| call_rpc(old.to_sym, pb_request) end rescue ArgumentError => e # Wrap a known issue where an instance method was defined in the class without # it being ignored with NON_RPC_METHODS. raise ArgumentError, "#{e.message} (Note: This could mean that you need to add the method #{old} to the NON_RPC_METHODS list)" end