diff options
author | Leon Breedt <bitserf@gmail.com> | 2005-04-17 17:20:44 +0000 |
---|---|---|
committer | Leon Breedt <bitserf@gmail.com> | 2005-04-17 17:20:44 +0000 |
commit | c11cc309fa7eb83f76237d022b119802bd7a4968 (patch) | |
tree | 631c7ee5922c8956d2cace6be5d9c4cd6dc31ef9 /actionwebservice/lib/action_web_service | |
parent | 0591c53efde948fd49a00aa23bdfc2ca26fca434 (diff) | |
download | rails-c11cc309fa7eb83f76237d022b119802bd7a4968.tar.gz rails-c11cc309fa7eb83f76237d022b119802bd7a4968.tar.bz2 rails-c11cc309fa7eb83f76237d022b119802bd7a4968.zip |
add backwards compatibility for the public API change made to #api_methods, as it is
being used in some apps.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1197 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/lib/action_web_service')
-rw-r--r-- | actionwebservice/lib/action_web_service/api.rb | 22 | ||||
-rw-r--r-- | actionwebservice/lib/action_web_service/support/signature_types.rb | 15 |
2 files changed, 31 insertions, 6 deletions
diff --git a/actionwebservice/lib/action_web_service/api.rb b/actionwebservice/lib/action_web_service/api.rb index 87ac1b164e..d4a42f99ef 100644 --- a/actionwebservice/lib/action_web_service/api.rb +++ b/actionwebservice/lib/action_web_service/api.rb @@ -204,6 +204,16 @@ module ActionWebService # :nodoc: h end + # Backwards compatibility with previous API + def [](sig_type) + case sig_type + when :expects + @expects.map{|x| compat_signature_entry(x)} + when :returns + @returns.map{|x| compat_signature_entry(x)} + end + end + # String representation of this method def to_s fqn = "" @@ -215,6 +225,18 @@ module ActionWebService # :nodoc: end private + def compat_signature_entry(entry) + if entry.array? + [compat_signature_entry(entry.element_type)] + else + if entry.spec.is_a?(Hash) + {entry.spec.keys.first => entry.type_class} + else + entry.type_class + end + end + end + def friendly_param(type, show_name=true) name = type.name.to_s type_type = type.array?? type.element_type.type.to_s : type.type.to_s diff --git a/actionwebservice/lib/action_web_service/support/signature_types.rb b/actionwebservice/lib/action_web_service/support/signature_types.rb index 65f63d16e1..4ab4a08d9b 100644 --- a/actionwebservice/lib/action_web_service/support/signature_types.rb +++ b/actionwebservice/lib/action_web_service/support/signature_types.rb @@ -10,19 +10,20 @@ module ActionWebService # :nodoc: end def canonical_signature_entry(spec, i) + orig_spec = spec name = "param#{i}" if spec.is_a?(Hash) name, spec = spec.keys.first, spec.values.first end type = spec if spec.is_a?(Array) - ArrayType.new(canonical_signature_entry(spec[0], 0), name) + ArrayType.new(orig_spec, canonical_signature_entry(spec[0], 0), name) else type = canonical_type(type) if type.is_a?(Symbol) - BaseType.new(type, name) + BaseType.new(orig_spec, type, name) else - StructuredType.new(type, name) + StructuredType.new(orig_spec, type, name) end end end @@ -126,11 +127,13 @@ module ActionWebService # :nodoc: class BaseType # :nodoc: include SignatureTypes + attr :spec attr :type attr :type_class attr :name - def initialize(type, name) + def initialize(spec, type, name) + @spec = spec @type = canonical_type(type) @type_class = canonical_type_class(@type) @name = name @@ -152,8 +155,8 @@ module ActionWebService # :nodoc: class ArrayType < BaseType # :nodoc: attr :element_type - def initialize(element_type, name) - super(Array, name) + def initialize(spec, element_type, name) + super(spec, Array, name) @element_type = element_type end |