# Get info from object\_id

**URL:** <https://www.ruby-forum.com/t/get-info-from-object-id/105569>\
**Category:** Ruby\
**Created:** [May 31, 2007, 6:24am UTC](https://www.ruby-forum.com/t/get-info-from-object-id/105569 "2007-05-31T06:24:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 31, 2007, 6:24am UTC](https://www.ruby-forum.com/t/get-info-from-object-id/105569/1 "2007-05-31T06:24:13Z")

</div>

Hi All,

apologies in advance if this is so stupid for you (my feeble mind is  
working feebly 🙂

so here goes,

Given an object\_id, how do i get back the object that id stands for?

i’m looking for something like,

```
a=[1,2,3]
x=a.object_id
b=Object.id_to_object(x) #-> returns object pointed by a wc [1,2,3]
b.class #-> returns Array
b #-> [1,2,3]
b == a #-> true

```

thank you and kind regards -botp

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 31, 2007, 7:05am UTC](https://www.ruby-forum.com/t/get-info-from-object-id/105569/2 "2007-05-31T07:05:15Z")

</div>

Peña wrote:

> Given an object\_id, how do i get back the object that id stands for?

ObjectSpace.\_id2ref is what you’re looking for.

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 31, 2007, 7:21am UTC](https://www.ruby-forum.com/t/get-info-from-object-id/105569/3 "2007-05-31T07:21:16Z")

</div>

From: Joel VanderWerf [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] :

# \> Given an object\_id, how do i get back the object that id stands for?

# 

# ObjectSpace.\_id2ref is what you’re looking for.

yikes! objectspace is the key word. should have done qri object -Osa in  
the first place. arrghhh…

many thanks again, Joel.  
kind regards -botp

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 31, 2007, 6:46pm UTC](https://www.ruby-forum.com/t/get-info-from-object-id/105569/4 "2007-05-31T18:46:43Z")

</div>

Peña wrote:

> yikes! objectspace is the key word. should have done qri object -Osa in the first place. arrghhh…

Thanks for reminding me about qri.

What does the “s” do? I see “a”, but not “s” in the help for -O:

```
 -O, --order ORDER Specify lookup order.
                                  (default: eEnNpPxX)
                                  Uppercase: case-indep.
                                  e:exact n:nested p:partial

```

(completion)  
x:nested and partial m:complete  
namespace  
f:complete both class and method  
a:match method name anywhere

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 1, 2007, 5:28am UTC](https://www.ruby-forum.com/t/get-info-from-object-id/105569/5 "2007-06-01T05:28:46Z")

</div>

From: Joel VanderWerf [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] :

# Peña wrote:

# \> yikes! objectspace is the key word. should have done qri

# object -Osa in the first place. arrghhh…

# 

# Thanks for reminding me about qri.

# 

# What does the “s” do? I see “a”, but not “s” in the help for -O:

# 

# -O, --order ORDER Specify lookup order.

# (default: eEnNpPxX)

# Uppercase: case-indep.

# e:exact n:nested p:partial

# (completion)

# x:nested and partial m:complete

# namespace

# f:complete both class and method

# a:match method name anywhere

Oh, i’m sorry, i tend to mixup qri options with ls (i usually do ls  
-oSa). I used -S for full text, so that should be

qri object -SOa

I usually pipe it then to less, since it’s full text search output,

qri object -SOa | less

On this current case, i should have taken a quick peek first by piping  
it to grep like eg,

C:\family\ruby\>qri object -SOa | less | grep -i object\_id  
… r = ObjectSpace.\_id2ref(s.object\_id) #=\> ‘I am a string’  
… ethod: object\_id  
… Document-method: object\_id  
and no two active objects will share an id. Object#object\_id is a  
share an id. Object#object\_id is a different concept from the :name  
Found in system Object#object\_id  
objects will share an id. Object#object\_id is a different concept  
and no two active objects will share an id. Object#object\_id is a  
share an id. Object#object\_id is a different concept from the :name  
… Soon-to-be deprecated version of Object#object\_id.  
… p res.body.object\_id # 538149362  
… p res.read\_body.object\_id # 538149362

There, first hit hints at id2ref…

btw, this is qri, wc is the slower brother of the faster fri; but then  
qri is a lot faster than the original ri, but you were much faster :),  
so…

thanks and kind regards -botp
