<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>init.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,51 +3,13 @@ require 'activesupport'
 module Morph
   VERSION = &quot;0.2.4&quot;
 
-  def self.object_from_key key
-    begin
-      name = key.to_s
-      type = &quot;Morph::#{name}&quot;.constantize
-    rescue NameError =&gt; e
-      Morph.const_set name, Class.new
-      type = &quot;Morph::#{name}&quot;.constantize
-      type.send(:include, Morph)
-    end
-    object = type.new
-  end
-
-  def self.add_to_object object, attributes
-    attributes.each do |key, value|
-      attribute = key.gsub(':',' ')
-      attribute = attribute.underscore
-
-      if value.is_a?(String)
-        object.morph(attribute, value)
-      elsif value.is_a?(Array)
-        array = value
-        if array.size &gt; 0 &amp;&amp; array.collect(&amp;:class).uniq == [Hash]
-          array = array.collect do |hash|
-            child = object_from_key key.singularize
-            add_to_object child, hash
-            child
-          end
-        end
-
-        object.morph(attribute.pluralize, array)
-      elsif value.is_a? Hash
-        child_object = object_from_key key
-        add_to_object child_object, value
-        object.morph(attribute, child_object)
-      end
-    end
-  end
-
-  def self.from_hash hash
+  def self.from_hash hash, namespace=Morph
     if hash.keys.size == 1
       key = hash.keys.first
-      object = object_from_key key
+      object = object_from_key key, namespace
       if hash[key].is_a? Hash
         attributes = hash[key]
-        add_to_object object, attributes
+        add_to_object object, attributes, namespace
       end
       object
     else
@@ -61,6 +23,47 @@ module Morph
     base.send(:include, MethodMissing)
   end
 
+  private
+    def self.object_from_key key, namespace
+      begin
+        name = key.to_s
+        type = &quot;#{namespace.name}::#{name}&quot;.constantize
+      rescue NameError =&gt; e
+        namespace.const_set name, Class.new
+        type = &quot;#{namespace.name}::#{name}&quot;.constantize
+        type.send(:include, Morph)
+      end
+      object = type.new
+    end
+
+    def self.add_to_object object, attributes, namespace
+      attributes.each do |key, value|
+        attribute = key.gsub(':',' ')
+        attribute = attribute.underscore
+
+        if value.is_a?(String)
+          object.morph(attribute, value)
+        elsif value.is_a?(Array)
+          array = value
+          if array.size &gt; 0 &amp;&amp; array.collect(&amp;:class).uniq == [Hash]
+            array = array.collect do |hash|
+              child = object_from_key key.singularize, namespace
+              add_to_object child, hash, namespace
+              child
+            end
+          end
+
+          object.morph(attribute.pluralize, array)
+        elsif value.is_a? Hash
+          child_object = object_from_key key, namespace
+          add_to_object child_object, value, namespace
+          object.morph(attribute, child_object)
+        end
+      end
+    end
+
+  public
+
   module ClassMethods
 
     @@adding_morph_method = Hash.new {|hash,klass| hash[klass] = false }</diff>
      <filename>lib/morph.rb</filename>
    </modified>
    <modified>
      <diff>@@ -405,18 +405,21 @@ describe Morph do
           ]
         }
       }
-      company_details = Morph.from_hash(h)
-      company_details.class.name.should == 'Morph::CompanyDetails'
+      Object.const_set 'Company', Module.new
+      Company.const_set 'House', Module.new
+
+      company_details = Morph.from_hash(h, Company::House)
+      company_details.class.name.should == 'Company::House::CompanyDetails'
       company_details.class.morph_methods.include?('last_full_mem_date').should be_true
       company_details.class.morph_methods.include?('accounts').should be_true
 
-      company_details.accounts.class.name.should == 'Morph::Accounts'
+      company_details.accounts.class.name.should == 'Company::House::Accounts'
       company_details.accounts.overdue.should == 'NO'
       company_details.last_full_mem_date.should == &quot;2002-03-25&quot;
       company_details.sic_codes.sic_text.should == 'stadiums'
       company_details.reg_address.address_lines.should == [&quot;ST DAVID'S HOUSE&quot;, &quot;WEST WING&quot;, &quot;WOOD STREET&quot;, &quot;CARDIFF CF10 1ES&quot;]
 
-      company_details.search_items.first.class.name.should == 'Morph::SearchItem'
+      company_details.search_items.first.class.name.should == 'Company::House::SearchItem'
       company_details.search_items.first.data_set.should == 'LIVE'
       company_details.search_items.first.company_name.should == 'CANONGROVE LIMITED'
       # puts company_details.to_yaml</diff>
      <filename>spec/lib/morph_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d758143f6e0a6eacbeaa2a4135c7d3dccb044a0f</id>
    </parent>
  </parents>
  <author>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </author>
  <url>http://github.com/robmckinnon/morph/commit/c8a0aed47542ba2f9bc8c32b4cb7bf0f9fca8ca7</url>
  <id>c8a0aed47542ba2f9bc8c32b4cb7bf0f9fca8ca7</id>
  <committed-date>2009-03-16T15:56:12-07:00</committed-date>
  <authored-date>2009-03-16T15:56:12-07:00</authored-date>
  <message>can pass namespace to from_hash method</message>
  <tree>473edc0bd51f66afa814f25653b794d8bd33fb0c</tree>
  <committer>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </committer>
</commit>
