<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/lib/morph_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,7 @@
+v0.2.3. added Morph.from_hash method
+
+v0.2.2. changed rubygem requirement to be &gt;= 1.2 instead of = 1.2
+
 v0.2.1. better accomodation of unicode method names
 
 v0.2.0. added script_generate method; fixed bug occurring when two morph classes exist</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -11,6 +11,7 @@ begin
     m.description = File.readlines(&quot;README&quot;).first
     m.rubyforge_name = &quot;morph&quot;
     m.rdoc_options &lt;&lt; '--inline-source'
+    m.dependencies = [&quot;activesupport &gt;=2.0.2&quot;]
     m.rdoc_pattern = [&quot;README&quot;, &quot;CHANGELOG&quot;, &quot;LICENSE&quot;]
   end
 </diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,49 @@
+require 'activesupport'
+
 module Morph
-  VERSION = &quot;0.2.1&quot;
+  VERSION = &quot;0.2.3&quot;
+
+  def self.object_from_key key
+    begin
+      name = key.to_s.singularize
+      type = name.constantize
+    rescue NameError =&gt; e
+      Object.const_set name, Class.new
+      type = name.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.tableize.singularize
+
+      if value.is_a?(String) || value.is_a?(Array)
+        object.morph(attribute, value)
+
+      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
+    if hash.keys.size == 1
+      key = hash.keys.first
+      object = object_from_key key
+      if hash[key].is_a? Hash
+        attributes = hash[key]
+        add_to_object object, attributes
+      end
+      object
+    else
+      raise 'hash must have single key'
+    end
+  end
 
   def self.included(base)
     base.extend ClassMethods</diff>
      <filename>lib/morph.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>spec/morph_spec.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>a8ed6d43795ab50b531db5e481d5b1b121e02a47</id>
    </parent>
  </parents>
  <author>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </author>
  <url>http://github.com/robmckinnon/morph/commit/0d5d85c17366d03547df3c2604f19c9bf3ddfa48</url>
  <id>0d5d85c17366d03547df3c2604f19c9bf3ddfa48</id>
  <committed-date>2009-03-13T19:15:31-07:00</committed-date>
  <authored-date>2009-03-13T19:15:31-07:00</authored-date>
  <message>work on Morph.from_hash() method</message>
  <tree>ae092989165d7107f9bbd86f5b358da77f2fda08</tree>
  <committer>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </committer>
</commit>
