module Pione::TupleSpace::TupleSpaceServerMethod
Public Class Methods
tuple_space_interface(name, opt={})
click to toggle source
# File lib/pione/tuple-space/tuple-space-server.rb, line 4 def self.tuple_space_interface(name, opt={}) define_method(name) do |*args, &b| # convert tuple space form _args = args.map do |obj| tuple_form = obj.respond_to?(:to_tuple_space_form) tuple_form ? obj.to_tuple_space_form : obj end # check arguments if opt.has_key?(:validator) opt[:validator].call(args) end # send a message to the tuple space result = @ts.__send__(name, *_args, &b) # convert the result to tuple object if converter = opt[:result] converter.call(result) else result end end end