# Object.id problem

**URL:** <https://rubytalk.org/t/object-id-problem/34909>\
**Category:** ruby-talk\
**Created:** [29 January 2007 17:28 UTC](https://rubytalk.org/t/object-id-problem/34909 "2007-01-29T17:28:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Amat](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Alex\_Amat](https://rubytalk.org/u/Alex_Amat)\
**Post date:** [29 January 2007 17:28 UTC](https://rubytalk.org/t/object-id-problem/34909/1 "2007-01-29T17:28:11Z")

</div>

Hi yet another Soap problem

I have a web service with a method called {}id however when i call this  
method [project.id](http://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-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![MikeGee](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@MikeGee](https://rubytalk.org/u/MikeGee)\
**Post date:** [29 January 2007 18:10 UTC](https://rubytalk.org/t/object-id-problem/34909/2 "2007-01-29T18:10:08Z")

</div>

> 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)

---

<div class="post-metadata">

**Author:** ![Alin\_Alin](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Alin\_Alin](https://rubytalk.org/u/Alin_Alin)\
**Post date:** [29 January 2007 18:22 UTC](https://rubytalk.org/t/object-id-problem/34909/3 "2007-01-29T18:22:50Z")

</div>

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-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Tom\_Pollard](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@Tom\_Pollard](https://rubytalk.org/u/Tom_Pollard)\
**Post date:** [29 January 2007 18:31 UTC](https://rubytalk.org/t/object-id-problem/34909/4 "2007-01-29T18:31:30Z")

</div>

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

> **···**
>
> 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

---

<div class="post-metadata">

**Author:** ![Alin\_Alin](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Alin\_Alin](https://rubytalk.org/u/Alin_Alin)\
**Post date:** [29 January 2007 18:26 UTC](https://rubytalk.org/t/object-id-problem/34909/5 "2007-01-29T18:26:51Z")

</div>

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&#39;\](http://localhost:8080/axis/Ids.jws&#39;%5C))  
drv.add\_method("id")  
puts drv.id

2:

#!/usr/bin/ruby  
require 'soap/wsdlDriver'  
wsdl = "[http://localhost:8080/axis/Ids.jws?wsdl&quot](http://localhost:8080/axis/Ids.jws?wsdl&quot);  
driver = SOAP::WSDLDriverFactory.new(wsdl).create\_rpc\_driver  
puts driver.id

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Tim\_Hunter2](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Tim\_Hunter2](https://rubytalk.org/u/Tim_Hunter2)\
**Post date:** [29 January 2007 18:50 UTC](https://rubytalk.org/t/object-id-problem/34909/6 "2007-01-29T18:50:05Z")

</div>

Tom Pollard 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\>

> **···**
>
> > On Jan 29, 2007, at 12:28 PM, Alex Amat wrote:

---

<div class="post-metadata">

**Author:** ![Alex\_Amat](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Alex\_Amat](https://rubytalk.org/u/Alex_Amat)\
**Post date:** [1 February 2007 10:19 UTC](https://rubytalk.org/t/object-id-problem/34909/7 "2007-02-01T10:19:31Z")

</div>

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  
&nbsp;&nbsp;&nbsp;puts [project.id](http://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-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Tom\_Pollard](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@Tom\_Pollard](https://rubytalk.org/u/Tom_Pollard)\
**Post date:** [29 January 2007 19:03 UTC](https://rubytalk.org/t/object-id-problem/34909/8 "2007-01-29T19:03:50Z")

</div>

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

> **···**
>
> 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.

---

<div class="post-metadata">

**Author:** ![Dan\_Manges](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@Dan\_Manges](https://rubytalk.org/u/Dan_Manges)\
**Post date:** [29 January 2007 19:15 UTC](https://rubytalk.org/t/object-id-problem/34909/9 "2007-01-29T19:15:06Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![Tom\_Pollard](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@Tom\_Pollard](https://rubytalk.org/u/Tom_Pollard)\
**Post date:** [29 January 2007 19:41 UTC](https://rubytalk.org/t/object-id-problem/34909/10 "2007-01-29T19:41:33Z")

</div>

Thanks!

Tom

> **···**
>
> 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\>
