Jason Fox wrote:

> I have a service method that takes a PaymentMethod which can either be a
> CreditCard or a PayPal account.  When I request the service and pass one
> or the other it always comes over as a PaymentMethod; the service
> doesn't seem to know that the parameter is really a CreditCard or
> PayPal.

I tracked down the issue to the cast_to_structured_type method of 
casting.rb. Essentially, a condition needs to be added that would 
effectively cause the code to not attempt to "cast" the parameter if it 
is derived from the type specified in the API declaration. Here's a 
one-line modification:

  # lib/action_web_service/castings.rb - line 120
  obj = value if canonical_type(value.class) == 
canonical_type(signature_type.type)

And here's how it would read after the patch along with the next 
unmodified line (121) for reference:

  obj = value if canonical_type(value.class) == 
canonical_type(signature_type.type) or 
derived_from?(signature_type.type, value.class)
  obj ||= signature_type.type_class.new

I am going to look into submitting a patch. Can anyone think of why this 
shouldn't work this way?  I am also asking the priest who resurrected 
this code from the dead.

http://www.datanoise.com/articles/2008/7/2/actionwebservice-is-back

Jason

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to