From aaea48fe9826b9e5d2d5b92795a297b8f238c58d Mon Sep 17 00:00:00 2001 From: Leon Breedt Date: Sat, 2 Apr 2005 21:03:36 +0000 Subject: * collapse 'ws' back into protocols, it just added complexity and indirection, and was hard to extend. * extract casting into seperate support file * ensure casting always does the right thing for return values, should fix interoperability issues with Ecto and possibly other XML-RPC clients * add functional unit tests for scaffolding * represent signature items with classes instead of symbols/Class objects, much more flexible * tweak logging to always show casted versions of parameters and return values, if possible. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1072 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionwebservice/lib/action_web_service/struct.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'actionwebservice/lib/action_web_service/struct.rb') diff --git a/actionwebservice/lib/action_web_service/struct.rb b/actionwebservice/lib/action_web_service/struct.rb index d4e2ba9ce6..c5e6346bfa 100644 --- a/actionwebservice/lib/action_web_service/struct.rb +++ b/actionwebservice/lib/action_web_service/struct.rb @@ -33,11 +33,20 @@ module ActionWebService send(name.to_s) end + # Iterates through each member + def each_pair(&block) + self.class.members.each do |name, type| + yield name, type + end + end + class << self # Creates a structure member with the specified +name+ and +type+. Generates # accessor methods for reading and writing the member value. def member(name, type) - write_inheritable_hash("struct_members", name => WS::BaseTypes.canonical_param_type_class(type)) + name = name.to_sym + type = ActionWebService::SignatureTypes.canonical_signature_entry({ name => type }, 0) + write_inheritable_hash("struct_members", name => type) class_eval <<-END def #{name}; @#{name}; end def #{name}=(value); @#{name} = value; end @@ -47,6 +56,10 @@ module ActionWebService def members # :nodoc: read_inheritable_attribute("struct_members") || {} end + + def member_type(name) # :nodoc: + members[name.to_sym] + end end end end -- cgit v1.2.3