Sha256: 3843b6726cafe0ac9d0a47a63876776404d316907c5451f6593d5b3e86bb8b04

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

require 'eventmachine'
require 'bertrpc'

module BERTRPC
  class Action

    [:execute, :write, :transaction, :connect_to].each do |m|
      remove_method m if method_defined?(m)
    end

    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.6 lib/bertrem/action.rb