<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,7 +2,7 @@ Morph allows you to emerge class definitions via calling assignment methods; mix
 
 
 
-== Morph example with Hpricot
+== Morph playing with +Hpricot+
 
 Here's example code showing Morph playing with Hpricot:
 
@@ -36,16 +36,18 @@ What new methods do we have?
 
 Ah-ha, so we have a name attribute now:
 
- why.name #=&gt; &quot;why the lucky stiff&quot;
+ why.name # =&gt; &quot;why the lucky stiff&quot;
 
 
 Let's add some of why's projects:
 
- why.projects = %w[shoes hacketyhack camping hoodwinkd hpricot markaby mousehole parkplace poignant sandbox]
+ why.projects = %w[shoes hacketyhack camping hoodwinkd hpricot
+                  markaby mousehole parkplace poignant sandbox]
 
 That why's a productive fellow! Note new accessor methods have been added:
 
- Hubbit.morph_methods # =&gt; [&quot;email&quot;, &quot;email=&quot;, &quot;name&quot;, &quot;name=&quot;, &quot;projects&quot;, &quot;projects=&quot;]
+ Hubbit.morph_methods
+ # =&gt; [&quot;email&quot;, &quot;email=&quot;, &quot;name&quot;, &quot;name=&quot;, &quot;projects&quot;, &quot;projects=&quot;]
 
 
 Let's do some more morphing:
@@ -54,66 +56,71 @@ Let's do some more morphing:
 
 Do we have more methods now?
 
- Hubbit.morph_methods # =&gt; [&quot;blog&quot;, &quot;blog=&quot;, &quot;company&quot;, &quot;company=&quot;, &quot;email&quot;, &quot;email=&quot;, &quot;location&quot;, &quot;location=&quot; &quot;name&quot;, &quot;name=&quot;, &quot;projects&quot;, &quot;projects=&quot;]
+ Hubbit.morph_methods
+ # =&gt; [&quot;blog&quot;, &quot;blog=&quot;, &quot;company&quot;, &quot;company=&quot;, &quot;email&quot;, &quot;email=&quot;,
+ #    &quot;location&quot;, &quot;location=&quot; &quot;name&quot;, &quot;name=&quot;, &quot;projects&quot;, &quot;projects=&quot;]
 
 So, a new company method has appeared:
 
  dhh.company #=&gt; &quot;37signals&quot;
 
 
+== Morph making sample Active Record line via +script_generate+
 
-== Morph example from Hash
+Time to generate an Active Record model? Get a sample script line like this:
 
-How about adding a hash of attribute values?
+ Hubbit.script_generate
+ # =&gt; &quot;ruby script/destroy rspec_model Hubbit;
+ #    ruby script/generate rspec_model Hubbit blog:string company:string
+ #        email:string location:string name:string projects:string&quot;
+
+or specify the generator:
+
+ Hubbit.script_generate :generator =&gt; 'model'
+ # =&gt; &quot;ruby script/destroy model Hubbit;
+ #     ruby script/generate model Hubbit blog:string company:string
+ #         email:string location:string name:string projects:string&quot;
+
+You'll have to edit this as it currently sets all data types to be string, and
+doesn't understand associations.
+
+
+== Morph setting hash of attributes via +morph+
 
  class Order; include Morph; end
  order = Order.new
+
+How about adding a hash of attribute values?
+
  order.morph :drink =&gt; 'tea', :spoons_of_sugar =&gt; 2, :milk =&gt; 'prefer soya thanks'
 
+Looks like we got 'em:
+
  order.drink  # =&gt; &quot;tea&quot;
  order.spoons_of_sugar  # =&gt; 2
  order.milk  # =&gt; &quot;prefer soya thanks&quot;
 
 
+== Morph obtaining hash of attributes via +morph_attributes+
 
-== Morph example hijacking method creation
-
-class VegieFoxes
-  include Morph
+Create an item:
 
-  def method_missing symbol, *args
-    if (is_writer = symbol.to_s =~ /=$/)
-      morph_method_missing(symbol, *args) do |base, attribute|
-        create_accessors base, attribute
-      end
-      send(symbol, *args)
-    else
-      super
-    end
-  end
+ class Item; include Morph; end
+ item = Item.new
+ item.morph :name =&gt; 'spinach', :cost =&gt; 0.50
 
-  private
-  def create_accessors base, attribute
-    base.class_eval &quot;attr_reader :#{attribute}&quot;
+Now an order:
 
-    base.class_def(&quot;#{attribute}=&quot;) do |value|
-      is_meat = %w[bacon ham].include? value
-      value = is_meat ? 'spinach' : value
-      instance_variable_set &quot;@#{attribute}&quot;.to_sym, value
-    end
-  end
-end
-
-foxes = VegieFoxes.new
+ class Order; include Morph; end
+ order = Order.new
+ order.no = 123
+ order.items = [item]
 
-foxes.chunky = 'bacon'
-foxes.inspect # =&gt; #&lt;VegieFoxes @chunky=&quot;spinach&quot;&gt;
+Want to retrieve all that as a nested hash of values? No problem:
 
-foxes.chunky = 'cheese'
-puts foxes.inspect # =&gt; #&lt;VegieFoxes @chunky=&quot;cheese&quot;&gt;
+ order.morph_attributes
+ # =&gt; {:items=&gt;[{:name=&gt;&quot;spinach&quot;, :cost=&gt;0.5}], :no=&gt;123}
 
-foxes.pet = 'ham'
-foxes.inspect # =&gt; #&lt;VegieFoxes @pet=&quot;spinach&quot;, @chunky=&quot;cheese&quot;&gt;
 
 == Last bits
 </diff>
      <filename>README</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bb29d423fb0abbcb7383eb30fc6a1ad226a20cdf</id>
    </parent>
  </parents>
  <author>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </author>
  <url>http://github.com/robmckinnon/morph/commit/7ca699ba35a0566d2fba5df3c7413076918ba8c3</url>
  <id>7ca699ba35a0566d2fba5df3c7413076918ba8c3</id>
  <committed-date>2008-05-01T10:18:25-07:00</committed-date>
  <authored-date>2008-05-01T10:18:25-07:00</authored-date>
  <message>updated for 0.2.0 release</message>
  <tree>97095e416ebd9820b0c4b2f26642a96b7dcdb062</tree>
  <committer>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </committer>
</commit>
