<p>In the database I have a field named 'body' that has an XML in it. The 
method I created in the model looks like this:</p>

<pre><code>def self.get_personal_data_module(person_id) 
    person_module = find_by_person_id(person_id) 
    item_module = Hpricot(person_module.body) 
    personal_info = Array.new 
    personal_info = {:studies =&gt; (item_module/"studies").inner_html, 
                            :birth_place =&gt; (item_module/"birth_place").inner_html, 
                            :marrital_status =&gt; (item_module/"marrital_status").inner_html} 
    return personal_info 
end 
</code></pre>

<p>I want the function to return an object instead of an array. So I can 
use Module.studies instead of Model[:studies].</p>

This is relatively simple; you're getting an Array because the code is building one. If you wanted to return an object, you'd do something like this:
```
```
class PersonalData
  attr_accessor :studies
  attr_accessor :birth_place
  attr_accessor :marital_status

  def initialize(studies,birth_place,marital_status)
    @studies = studies
    @birth_place = birth_place
    @marital_status = marital_status
  end
end
```
```
And your translation code would look like:
```
```
def self.get_personal_data_module(person_id) 
  person_module = find_by_person_id(person_id) 
  item_module = Hpricot(person_module.body) 
  personal_info = PersonalData.new((item_module/"studies").inner_html,
                                   (item_module/"birth_place").inner_html,
                                   (item_module/"marital_status").innner_html)
  return personal_info 
end
```
```