Sha256: 77989f25bc542622605cfff96d4801680719b3aa8a18ad8f137d86d1bb7a5d35

Contents?: true

Size: 713 Bytes

Versions: 2

Compression:

Stored size: 713 Bytes

Contents

require 'bert'
require 'eventmachine'

module ProxyLocal
  module Protocol
    include EventMachine::Protocols::ObjectProtocol

    def serializer
      Serializer
    end

    def receive_object(object)
      object = [object] unless object.is_a?(Array)

      command, *args = object

      method_name = "receive_#{command}"

      if respond_to?(method_name) && [-1, args.size].include?(method(method_name).arity)
        send(method_name, *args)
      else
        receive_unknown(object)
      end
    end

    def send_object(*args)
      object = if args.size > 1
                 BERT::Tuple[*args]
               else
                 args.first
               end
      super(object)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proxylocal-0.3.1 lib/proxylocal/protocol.rb
proxylocal-0.3.0 lib/proxylocal/protocol.rb