# Design question - user data from two different sources

**URL:** <https://www.ruby-forum.com/t/design-question-user-data-from-two-different-sources/56346>\
**Category:** Rails\
**Created:** [March 30, 2006, 12:48pm UTC](https://www.ruby-forum.com/t/design-question-user-data-from-two-different-sources/56346 "2006-03-30T12:48:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![agnessa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@agnessa](https://www.ruby-forum.com/u/agnessa)\
**Post date:** [March 30, 2006, 12:48pm UTC](https://www.ruby-forum.com/t/design-question-user-data-from-two-different-sources/56346/1 "2006-03-30T12:48:27Z")

</div>

hello,

how would you go about this: I would like my app to be able to  
alternatively draw user data from two sources - a users table in a  
database and an LDAP server. By alternatively I mean it would be set up  
to draw from one of these sources, not both at the same time. I would  
like to have objects of type Person which I would use regardless of  
where this person is stored, so both the active record model and the  
ldap user model would have a common set of functions that they would be  
responding to and the application can ignore where the data is pulled  
from.

so what would be an elegant way of achieving this? I would appreciate a  
suggestion of some pattern of organising these models. What I’ve come up  
with so far are 3 classes - DbPerson and LDAPPerson, and a Person class  
which is supposed to be something like an interface. It has an if clause  
that checks the USE\_LDAP constant. Depending on this test it sets a  
@my\_class variable. Then it defines wrappers to all the common functions  
of the two models and calls the methods of the relevant model by using  
the @my\_class var. This works but it seems clumsy to me so I’m looking  
for insights 🙂

Thanks!

–  
Agnieszka
