Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed serialization of args.

  • Loading branch information...
commit 01a7059b9f0ca33958a5aae8a7a082199dd55cca 1 parent 491d44c
@steveWang steveWang authored
Showing with 19 additions and 17 deletions.
  1. +2 −2 lib/ruby-now.rb
  2. +17 −15 lib/util.rb
View
4 lib/ruby-now.rb
@@ -10,8 +10,8 @@ module RubyNow
def self.conn
@@conn
end
- def self.remoteCall
- Util.remoteCall
+ def self.remoteCall *args
+ Util.remoteCall.call(*args)
end
def self.registerFunction name, block
Util.registerFunction name, block
View
32 lib/util.rb
@@ -13,34 +13,36 @@ def self.registerFunction name, block
def self.processData hash
obj = hash['args'][0];
case hash['name']
- when 'rfc'
+ when 'closurecall'
self.callFunc(@@functions[obj['fqn']], obj['args'])
else
puts 'unidentified json, json'
end
end
- def self.serialize a
- ((a.is_a?(Hash) && a.has_key?('fqn')) ?
- (@@functions.has_key?(a['fqn']) ?
- @@functions[a['fqn']] :
- (@@closures.has_key?(a['fqn']) ?
- @@closures[a['fqn']] :
- self.remoteCall(a['fqn']))):
- (a.is_a?(Proc) ?
- (((@@closures[a.to_s] = a) && true) ||
- {"fqn" => a.to_s}) :
- a))
+ def self.serializeArgs args
+ args.collect {|a|
+ ((a.is_a?(Hash) && a.has_key?('fqn')) ?
+ (@@functions.has_key?(a['fqn']) ?
+ @@functions[a['fqn']] :
+ (@@closures.has_key?(a['fqn']) ?
+ @@closures[a['fqn']] :
+ self.remoteCall(a['fqn']))):
+ (a.is_a?(Proc) ?
+ (((@@closures[a.to_s] = a) && true) ||
+ {"fqn" => a.to_s}) :
+ a))
+ }
end
def self.callFunc func, args
- func.call *(args.collect(self.serialize))
+ func.call *(self.serializeArgs args)
end
def self.remoteCall a
(lambda{|*args|
- self.send_data({ "name" => "rfc",
+ self.send_data({ "name" => "closurecall",
"args" => [{ "fqn" => a,
- "args" => args.collect(self.serialize) }] }.to_json)
+ "args" => (self.serializeArgs args)}] }.to_json)
})
end
Please sign in to comment.
Something went wrong with that request. Please try again.