Sha256: b57da29160b72ddb7f44eddfd050e44b53c164ed17be137358a043ee78350899

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

require 'eventmachine'
require 'bertrpc'

module BERTRPC
  class Action

    undef_method :execute
    undef_method :write
    undef_method :transaction
    undef_method :connect_to

    def execute
      transaction(encode_ruby_request(t[@req.kind, @mod, @fun, @args]))
      @svc.requests.unshift(EM::DefaultDeferrable.new).first
    end

    def write(bert)
      @svc.send_data([bert.length].pack("N"))
      @svc.send_data(bert)
    end

    def transaction(bert_request)
      if @req.options
        if @req.options[:cache] && @req.options[:cache][0] == :validation
          token = @req.options[:cache][1]
          info_bert = encode_ruby_request([:info, :cache, [:validation, token]])
          write(info_bert)
        end
      end

      write(bert_request)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bertrem-0.0.4 lib/bertrem/action.rb