# How: obj-class-A = A.new(obj-class-B) ? suppose class A is subset of class B

**URL:** <https://www.ruby-forum.com/t/how-obj-class-a-a-new-obj-class-b-suppose-class-a-is-subset-of-class-b/132236>\
**Category:** Rails\
**Created:** [March 18, 2008, 7:07am UTC](https://www.ruby-forum.com/t/how-obj-class-a-a-new-obj-class-b-suppose-class-a-is-subset-of-class-b/132236 "2008-03-18T07:07:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hei](https://www.ruby-forum.com/u/hei)\
**Post date:** [March 18, 2008, 7:07am UTC](https://www.ruby-forum.com/t/how-obj-class-a-a-new-obj-class-b-suppose-class-a-is-subset-of-class-b/132236/1 "2008-03-18T07:07:09Z")

</div>

RT~  
I mean create an object a-A by another object b-B.  
a-A is object of class A, b-B is object of class B.  
suppose A is ‘subset’ of B, em, I mean, all the attributes A have, you  
can find attributes with the same name in B.  
How can I gain this? re-write the ‘new’ method in A? or just define  
another method create\_via\_B(b-B)? so how ?

---

<div class="post-metadata">

**Author:** ![hei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hei](https://www.ruby-forum.com/u/hei)\
**Post date:** [March 18, 2008, 1:05pm UTC](https://www.ruby-forum.com/t/how-obj-class-a-a-new-obj-class-b-suppose-class-a-is-subset-of-class-b/132236/2 "2008-03-18T13:05:19Z")

</div>

I’m not sure if I fully understand what you’re trying to describe but  
it sounds like you want to look into Single Table Inheritance (STI).
