Class: BERTRPC::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/bertrem/action.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



11
12
13
14
# File 'lib/bertrem/action.rb', line 11

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

#transaction(bert_request) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bertrem/action.rb', line 21

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

#write(bert) ⇒ Object



16
17
18
19
# File 'lib/bertrem/action.rb', line 16

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