[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Object.id problem

Alex Amat

1/29/2007 5:28:00 PM

Hi yet another Soap problem

I have a web service with a method called {}id however when i call this
method project.id it returns the Object id instead of calling the method
id.

Any ideas on how to call the method id

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

9 Answers

MikeGee

1/29/2007 6:08:00 PM

0

> I have a web service with a method called {}id however when i call this
> method project.id it returns the Object id instead of calling the method
> id.
>
> Any ideas on how to call the method id

project.send(:id)

Alin Alin

1/29/2007 6:23:00 PM

0

Alex Amat wrote:
> Hi yet another Soap problem
>
> I have a web service with a method called {}id however when i call this
> method project.id it returns the Object id instead of calling the method
> id.
>
> Any ideas on how to call the method id

Hi Alex,

Can you tell us please, how do you make the call ? (maybe an example
will be helpful).

Thanks.

Alin.

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

Alin Alin

1/29/2007 6:27:00 PM

0

Alin Popa wrote:
> Alex Amat wrote:
>> Hi yet another Soap problem
>>
>> I have a web service with a method called {}id however when i call this
>> method project.id it returns the Object id instead of calling the method
>> id.
>>
>> Any ideas on how to call the method id
>
> Hi Alex,
>
> Can you tell us please, how do you make the call ? (maybe an example
> will be helpful).
>
> Thanks.
>
> Alin.

I've tried in 2 ways and it's working:

1:

#!/usr/bin/ruby
require 'soap/rpc/driver'
drv=SOAP::RPC::Driver.new('http://localhost:8080/axis/Ids.jws')
drv.add_method("id")
puts drv.id

2:

#!/usr/bin/ruby
require 'soap/wsdlDriver'
wsdl = "http://localhost:8080/axis/Ids.jws?wsdl"
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
puts driver.id


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

Tom Pollard

1/29/2007 6:32:00 PM

0


On Jan 29, 2007, at 12:28 PM, Alex Amat wrote:
> I have a web service with a method called {}id however when i call
> this
> method project.id it returns the Object id instead of calling the
> method
> id.
>
> Any ideas on how to call the method id

I've run into the same problem. My conclusion is that 'id' is
effectively a reserved method name in Ruby, and you simply need to
avoid creating your own 'id' method. I just don't see how a custom
'id' method could possibly avoid interfering with Object#id.

Tom

Tim Hunter

1/29/2007 6:42:00 PM

0

Tom Pollard wrote:
>
> On Jan 29, 2007, at 12:28 PM, Alex Amat wrote:
>> I have a web service with a method called {}id however when i call this
>> method project.id it returns the Object id instead of calling the method
>> id.
>>
>> Any ideas on how to call the method id
>
> I've run into the same problem. My conclusion is that 'id' is
> effectively a reserved method name in Ruby, and you simply need to avoid
> creating your own 'id' method. I just don't see how a custom 'id'
> method could possibly avoid interfering with Object#id.
>
> Tom
>

Use __id__ instead of just id.

C:\temp>irb
irb(main):001:0> class Foo
irb(main):002:1> def id
irb(main):003:2> return "HELLO"
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> f = Foo.new
=> #<Foo:0x2939490>
irb(main):007:0> f.id
=> "HELLO"
irb(main):008:0> f.__id__
=> 21613128
irb(main):009:0>

Tom Pollard

1/29/2007 7:04:00 PM

0


On Jan 29, 2007, at 1:50 PM, Tim Hunter wrote:
> Tom Pollard wrote:
>> On Jan 29, 2007, at 12:28 PM, Alex Amat wrote:
>>> I have a web service with a method called {}id however when i
>>> call this
>>> method project.id it returns the Object id instead of calling the
>>> method
>>> id.
>>>
>>> Any ideas on how to call the method id
>> I've run into the same problem. My conclusion is that 'id' is
>> effectively a reserved method name in Ruby, and you simply need to
>> avoid creating your own 'id' method. I just don't see how a
>> custom 'id' method could possibly avoid interfering with Object#id.
>> Tom
>
> Use __id__ instead of just id.

My concern was that other parts of the Ruby infrastructure would
depend on the 'id' method to be Object#id. Is Object#id really just
an alias for Object#__id__ , and so it's safe to redefine it?

Thanks,

Tom

Dan Manges

1/29/2007 7:12:00 PM

0

It's safe to define your own 'id' method - using .id to get the object
id is deprecated.

irb(main):001:0> Object.new.id
(irb):1: warning: Object#id will be deprecated; use Object#object_id
=> 24272204
irb(main):002:0> RUBY_VERSION
=> "1.8.4"
irb(main):003:0>

Dan Manges

Tom Pollard

1/29/2007 7:42:00 PM

0


On Jan 29, 2007, at 2:15 PM, Dan Manges wrote:
> It's safe to define your own 'id' method - using .id to get the object
> id is deprecated.
>
> irb(main):001:0> Object.new.id
> (irb):1: warning: Object#id will be deprecated; use Object#object_id
> => 24272204
> irb(main):002:0> RUBY_VERSION
> => "1.8.4"
> irb(main):003:0>

Thanks!

Tom


Alex Amat

2/1/2007 10:20:00 AM

0

Hi guys sorry for taking so long to answer I been away form the computer
for a bit.

The following is the code that i use to call the method id:

soap_client = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
soap_client.options["protocol.http.basic_auth"] << ['wsdl, user,
password]

@projects = soap_client.getProjects()
for project in @projects
puts project.id
end

and that gives me the Object#id not the 'project id' which is what I
need, if I could i would rewrite the method and call it getId but I did
not write it and I don't have access to it anyway.

Thanks for all your help




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