Ezra Zygmuntowicz
11/4/2006 2:18:00 AM
On Nov 3, 2006, at 6:10 PM, Stephane Wirtel wrote:
> Hi all,
>
> I would like to know if there is a way to simplify this code
>
> object.instance_of? WSDL::XMLSchema::ComplexContent or
> object.instance_of? WSDL::XMLSchema::ComplexType or
> object.instance_of? WSDL::XMLSchema::SimpleType or
> object.instance_of? WSDL::XMLSchema::SimpleRestriction or
> object.instance_of? WSDL::XMLSchema::Element or
> object.instance_of? WSDL::XMLSchema::Sequence or
> object.instance_of? XSD::QName or
> object.instance_of? WSDL::Message or
> object.instance_of? WSDL::Part or
> object.instance_of? WSDL::Service or
> object.instance_of? WSDL::Port or
> object.instance_of? WSDL::SOAP::Address or
> object.instance_of? WSDL::Binding or
> object.instance_of? WSDL::SOAP::Binding or
> object.instance_of? WSDL::OperationBinding or
> object.instance_of? WSDL::SOAP::Operation or
> object.instance_of? WSDL::Param or
> object.instance_of? WSDL::SOAP::Body or
> object.instance_of? WSDL::PortType or
> object.instance_of? WSDL::Operation or
> object.instance_of? WSDL::SOAP::Attribute
>
> ?
>
> Thanks
[
WSDL::XMLSchema::ComplexContent,
WSDL::XMLSchema::ComplexType,
WSDL::XMLSchema::SimpleType,
WSDL::XMLSchema::SimpleRestriction,
WSDL::XMLSchema::Element,
WSDL::XMLSchema::Sequence,
XSD::QName,
WSDL::Message,
WSDL::Part,
WSDL::Service,
WSDL::Port,
WSDL::SOAP::Address,
WSDL::Binding,
WSDL::SOAP::Binding,
WSDL::OperationBinding,
WSDL::SOAP::Operation,
WSDL::Param,
WSDL::SOAP::Body,
WSDL::PortType,
WSDL::Operation,
WSDL::SOAP::Attribute
].any? {|cls| object.instance_of? cls}
Thats one way to skin this cat. But I have to call code smell on
this whole check to see if this object is an instance of all these
classes. Maybe there is an easier way to accomplish what you want if
you expound on the question?
Cheers-
-- Ezra Zygmuntowicz
-- Lead Rails Evangelist
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)