Permalink
Browse files

Properly serialize/deserialize as seen fit.

  • Loading branch information...
1 parent 7295e9a commit 8df59195f5b5ba2f5835972b5dfabbb6b19fc189 @steveWang steveWang committed Aug 8, 2011
Showing with 11 additions and 10 deletions.
  1. +11 −10 lib/util.rb
View
@@ -19,7 +19,7 @@ def self.processData hash
puts 'unidentified json, json'
end
end
- def self.serializeArgs args
+ def self.readyArgs args
args.collect {|a|
((a.is_a?(Hash) && a.has_key?('fqn')) ?
(@@functions.has_key?(a['fqn']) ?
@@ -28,22 +28,23 @@ def self.serializeArgs args
@@closures[a['fqn']] :
self.remoteCall(a['fqn']))):
(a.is_a?(Proc) ?
- (((@@closures[a.to_s] = a) && false) ||
- {"fqn" => a.to_s}) :
- a))
+ (((@@functions.has_key?(a['fqn']) ||
+ @@closures[a.to_s] = a) &&
+ {"fqn" => a.to_s})) :
+ a))
}
end
def self.callFunc func, args
- func.call *(self.serializeArgs args)
+ func.call *(self.readyArgs args)
end
def self.remoteCall a
- (lambda{|*args|
- self.send_data({ "name" => "closurecall",
- "args" => [{ "fqn" => a,
- "args" => (self.serializeArgs args)}] }.to_json)
- })
+ lambda{|*args|
+ self.send_data({ "name" => "closurecall",
+ "args" => [{ "fqn" => a,
+ "args" => (self.readyArgs args)}] }.to_json)
+ }
end
def self.send_data str

0 comments on commit 8df5919

Please sign in to comment.