<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,11 @@
+== 0.2.5
+* 1 minor tweak
+  * Classes can now be strings instead of constants so you don't have to worry about class definition order (this was all for technicalpickles, enjoy!)
+  
+== 0.2.4
+* 1 minor tweak
+  * Added a patch that allows even crazy namespaces to work
+  
 == 0.2.3
 * 1 minor tweak
   * bumped the version of libxml-ruby to 1.1.3</diff>
      <filename>History</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,10 @@ module HappyMapper
       
       @xml_type = self.class.to_s.split('::').last.downcase
     end
+    
+    def constant
+      @constant ||= constantize(type)
+    end
         
     def from_xml_node(node, namespace)
       if primitive?
@@ -41,13 +45,13 @@ module HappyMapper
             end
 
             begin
-              type.send(options[:parser].to_sym, value)
+              constant.send(options[:parser].to_sym, value)
             rescue
               nil
             end
           end
         else
-          type.parse(node, options)
+          constant.parse(node, options)
         end
       end
     end
@@ -62,7 +66,7 @@ module HappyMapper
     end
     
     def primitive?
-      Types.include?(type)
+      Types.include?(constant)
     end
     
     def element?
@@ -78,15 +82,15 @@ module HappyMapper
     end
     
     def typecast(value)
-      return value if value.kind_of?(type) || value.nil?
+      return value if value.kind_of?(constant) || value.nil?
       begin        
-        if    type == String    then value.to_s
-        elsif type == Float     then value.to_f
-        elsif type == Time      then Time.parse(value.to_s)
-        elsif type == Date      then Date.parse(value.to_s)
-        elsif type == DateTime  then DateTime.parse(value.to_s)
-        elsif type == Boolean   then ['true', 't', '1'].include?(value.to_s.downcase)
-        elsif type == Integer
+        if    constant == String    then value.to_s
+        elsif constant == Float     then value.to_f
+        elsif constant == Time      then Time.parse(value.to_s)
+        elsif constant == Date      then Date.parse(value.to_s)
+        elsif constant == DateTime  then DateTime.parse(value.to_s)
+        elsif constant == Boolean   then ['true', 't', '1'].include?(value.to_s.downcase)
+        elsif constant == Integer
           # ganked from datamapper
           value_to_i = value.to_i
           if value_to_i == 0 &amp;&amp; value != '0'
@@ -108,6 +112,21 @@ module HappyMapper
     end
     
     private
+      def constantize(type)
+        if type.is_a?(String)
+          names = type.split('::')
+          constant = Object
+          names.each do |name|
+            constant =  constant.const_defined?(name) ? 
+                          constant.const_get(name) : 
+                          constant.const_missing(name)
+          end
+          constant
+        else
+          type
+        end
+      end
+      
       def find(node, namespace, &amp;block)
         # this node has a custom namespace (that is present in the doc)
         if self.namespace &amp;&amp; node.namespaces.find_by_prefix(self.namespace)</diff>
      <filename>lib/happymapper/item.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
 module HappyMapper
-  Version = '0.2.4'
+  Version = '0.2.5'
 end</diff>
      <filename>lib/happymapper/version.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,9 @@
 require File.dirname(__FILE__) + '/spec_helper.rb'
 
+module Foo
+  class Bar; end
+end
+
 describe HappyMapper::Item do
   
   describe &quot;new instance&quot; do
@@ -24,6 +28,23 @@ describe HappyMapper::Item do
     end
   end
   
+  describe &quot;#constant&quot; do
+    it &quot;should just use type if constant&quot; do
+      item = HappyMapper::Item.new(:foo, String)
+      item.constant.should == String
+    end
+    
+    it &quot;should convert string type to constant&quot; do
+      item = HappyMapper::Item.new(:foo, 'String')
+      item.constant.should == String
+    end
+    
+    it &quot;should convert string with :: to constant&quot; do
+      item = HappyMapper::Item.new(:foo, 'Foo::Bar')
+      item.constant.should == Foo::Bar
+    end
+  end
+  
   describe &quot;#method_name&quot; do
     it &quot;should convert dashes to underscores&quot; do
       item = HappyMapper::Item.new(:'foo-bar', String, :tag =&gt; 'foobar')</diff>
      <filename>spec/happymapper_item_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -274,72 +274,76 @@ describe HappyMapper do
   
   describe &quot;being included into another class&quot; do
     before do
-      Foo.instance_variable_set(&quot;@attributes&quot;, {})
-      Foo.instance_variable_set(&quot;@elements&quot;, {})
+      @klass = Class.new do
+        include HappyMapper
+        
+        def self.to_s
+          'Foo'
+        end
+      end
     end
-    class Foo; include HappyMapper end
     
     it &quot;should set attributes to an array&quot; do
-      Foo.attributes.should == []
+      @klass.attributes.should == []
     end
     
     it &quot;should set @elements to a hash&quot; do
-      Foo.elements.should == []
+      @klass.elements.should == []
     end
     
     it &quot;should allow adding an attribute&quot; do
       lambda {
-        Foo.attribute :name, String
-      }.should change(Foo, :attributes)
+        @klass.attribute :name, String
+      }.should change(@klass, :attributes)
     end
     
     it &quot;should allow adding an attribute containing a dash&quot; do
       lambda {
-        Foo.attribute :'bar-baz', String
-      }.should change(Foo, :attributes)
+        @klass.attribute :'bar-baz', String
+      }.should change(@klass, :attributes)
     end
 
     it &quot;should be able to get all attributes in array&quot; do
-      Foo.attribute :name, String
-      Foo.attributes.size.should == 1
+      @klass.attribute :name, String
+      @klass.attributes.size.should == 1
     end
     
     it &quot;should allow adding an element&quot; do
       lambda {
-        Foo.element :name, String
-      }.should change(Foo, :elements)
+        @klass.element :name, String
+      }.should change(@klass, :elements)
     end
 
     it &quot;should allow adding an element containing a dash&quot; do
       lambda {
-        Foo.element :'bar-baz', String
-      }.should change(Foo, :elements)
+        @klass.element :'bar-baz', String
+      }.should change(@klass, :elements)
 
     end
     
     it &quot;should be able to get all elements in array&quot; do
-      Foo.element(:name, String)
-      Foo.elements.size.should == 1
+      @klass.element(:name, String)
+      @klass.elements.size.should == 1
     end
     
     it &quot;should allow has one association&quot; do
-      Foo.has_one(:user, User)
-      element = Foo.elements.first
+      @klass.has_one(:user, User)
+      element = @klass.elements.first
       element.name.should == 'user'
       element.type.should == User
       element.options[:single] = true
     end
     
     it &quot;should allow has many association&quot; do
-      Foo.has_many(:users, User)
-      element = Foo.elements.first
+      @klass.has_many(:users, User)
+      element = @klass.elements.first
       element.name.should == 'users'
       element.type.should == User
       element.options[:single] = false
     end
 
     it &quot;should default tag name to lowercase class&quot; do
-      Foo.tag_name.should == 'foo'
+      @klass.tag_name.should == 'foo'
     end
     
     it &quot;should default tag name of class in modules to the last constant lowercase&quot; do
@@ -348,17 +352,17 @@ describe HappyMapper do
     end
     
     it &quot;should allow setting tag name&quot; do
-      Foo.tag('FooBar')
-      Foo.tag_name.should == 'FooBar'
+      @klass.tag('FooBar')
+      @klass.tag_name.should == 'FooBar'
     end
     
     it &quot;should allow setting a namespace&quot; do
-      Foo.namespace(namespace = &quot;foo&quot;)
-      Foo.namespace.should == namespace
+      @klass.namespace(namespace = &quot;foo&quot;)
+      @klass.namespace.should == namespace
     end
 
     it &quot;should provide #parse&quot; do
-      Foo.should respond_to(:parse)
+      @klass.should respond_to(:parse)
     end
   end
   
@@ -551,6 +555,19 @@ describe HappyMapper do
     property.value.should == '85301'
   end
   
+  it &quot;should allow instantiating with a string&quot; do
+    module StringFoo
+      class Bar
+        include HappyMapper
+        has_many :things, 'StringFoo::Thing'
+      end
+      
+      class Thing
+        include HappyMapper
+      end
+    end
+  end
+  
   xit &quot;should parse family search xml&quot; do
     tree = FamilySearch::FamilyTree.parse(fixture_file('family_tree.xml'))
     tree.version.should == '1.0.20071213.942'</diff>
      <filename>spec/happymapper_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>741b7d5b007c0832807ce9f86c7800efc7f8bd51</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/happymapper/commit/a377d9776f359448c58cfc9379aeb1af05dc7298</url>
  <id>a377d9776f359448c58cfc9379aeb1af05dc7298</id>
  <committed-date>2009-05-27T20:42:05-07:00</committed-date>
  <authored-date>2009-05-27T20:42:05-07:00</authored-date>
  <message>Classes can now be strings instead of constants so you don't have to worry about class definition order (this was all for technicalpickles, enjoy!)</message>
  <tree>12afd5400d0c07488fa07cc1c4542e4de3c9275a</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
