<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -10,6 +10,8 @@ module Pancake
       # formats it supports. The second is hash of options. Typically this 
       # hash is generated by the publish declaration in a controller.
       #
+      # TODO: Allow params to be grouped together
+      #
       # :api: private
       def initialize(default_formats, opts)
        # Extract the params &#8212; excluding configuration &#8212; and turn the keys into
@@ -36,6 +38,7 @@ module Pancake
       #
       # :api: private
       def validate_and_coerce(incoming_params)
+        missing = []
         params.each do |name, config|
           type, default, opts = config
           value = incoming_params[name]
@@ -44,13 +47,13 @@ module Pancake
             incoming_params[name] = send(&quot;validate_and_coerce_#{type}&quot;, value, opts)
           else
             if default == :req
-              raise &quot;Required parameter #{name} is missing&quot;
+              missing &lt;&lt; [name, type]
             elsif default != :opt
               incoming_params[name] = default
             end
           end
         end
-        incoming_params
+        [incoming_params, missing]
       end
       
       private
@@ -70,6 +73,14 @@ module Pancake
       def validate_and_coerce_date(value, opts)
         Date.parse(value)
       end
+      
+      # Turns the incoming value into a string. The opts argument is
+      # only there to satisfy the interface. it is not used.
+      #
+      # :api: private
+      def validate_and_coerce_string(value, opts)
+        value.to_s
+      end
 
       # Extracts the format options from a hash. It is used to compile the 
       # list of formats that an action can provide. It accepts an array of</diff>
      <filename>lib/pancake/more/controller/action_options.rb</filename>
    </modified>
    <modified>
      <diff>@@ -79,6 +79,13 @@ module Pancake
       as_declaration(:date, *args)
     end
     
+    # Coerces the specified parameter into a string.
+    #
+    # :api: public
+    def self.as_string(*args) 
+      as_declaration(:string, *args)
+    end
+    
     # Takes a parameters hash, and validates each entry against the options
     # defined for this action. It will flag required params when missing, 
     # insert defaults or coerce values into the desired type. It mutates</diff>
      <filename>lib/pancake/more/controller/publish.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 describe &quot;Pancake::Controller publish declaration&quot; do
   before(:all) do
     class Test &lt; Pancake::Controller
+      provides :html
       
       publish
       def simple_publish; end
@@ -21,6 +22,17 @@ describe &quot;Pancake::Controller publish declaration&quot; do
       
       publish :only_provides =&gt; :xml
       def only_provides_test; end
+      
+      publish :name =&gt; as_string(:opt)
+      def optional_test; end
+      
+      publish :provides =&gt; [:json, :txt],
+              :id       =&gt; as_integer(:req), 
+              :name     =&gt; as_string(&quot;Campion&quot;), 
+              :melon    =&gt; as_integer(50),
+              :jam      =&gt; as_string(:opt),
+              :squeeze  =&gt; as_string(:req)
+      def complex_test; end
     end
   end
   
@@ -29,20 +41,28 @@ describe &quot;Pancake::Controller publish declaration&quot; do
   end
   
   it &quot;should coerce a parameter into an integer&quot; do
-    params = Test.validate_and_coerce_params('integer_test', 'id' =&gt; &quot;30&quot;)
+    params, missing = Test.validate_and_coerce_params('integer_test', 'id' =&gt; &quot;30&quot;)
     params['id'].should == 30
   end
   
   it &quot;should coerce a parameter into a date&quot; do
     date = Date.parse(&quot;2009/07/05&quot;)
-    params = Test.validate_and_coerce_params('date_test', 'start' =&gt; &quot;2009/07/05&quot;)
+    params, missing = Test.validate_and_coerce_params('date_test', 'start' =&gt; &quot;2009/07/05&quot;)
     params['start'].should == date
   end
   
-  it &quot;should allow parameters to be optional&quot;
+  it &quot;should flag required params that are missing&quot; do
+    params, missing = Test.validate_and_coerce_params('integer_test', {})
+    missing.include?(['id', :integer]).should == true
+  end
+  
+  it &quot;should allow parameters to be optional&quot; do
+    params, missing = Test.validate_and_coerce_params('optional_test', {})
+    missing.empty?.should == true
+  end
   
   it &quot;should return a default value for a parameter&quot; do
-    params = Test.validate_and_coerce_params('default_test', {})
+    params, missing = Test.validate_and_coerce_params('default_test', {})
     params['page'].should == 12
   end
   
@@ -53,4 +73,16 @@ describe &quot;Pancake::Controller publish declaration&quot; do
   it &quot;should replace the list of formats allowed for an action&quot; do
     Test.actions['only_provides_test'].formats.should == [:xml]
   end
+  
+  it &quot;should allow complex declarations&quot; do
+    input = {'id' =&gt; &quot;30&quot;, 'name' =&gt; &quot;Purslane&quot;}
+    params, missing = Test.validate_and_coerce_params('complex_test', input)
+    params['id'].should == 30
+    params['name'].should == &quot;Purslane&quot;
+    params['melon'].should == 50
+    params['jame'].should be_nil
+    missing.include?(['squeeze', :string]).should == true
+    
+    Test.actions['complex_test'].formats.should == [:html, :json, :txt]
+  end
 end</diff>
      <filename>spec/more/controller/publish_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>85bc664908755223a00e32d6011646af7cc5f21a</id>
    </parent>
  </parents>
  <author>
    <name>Luke Sutton</name>
    <email>luke.sutton@gmail.com</email>
  </author>
  <url>http://github.com/hassox/pancake/commit/2dcb0fc431f93b04d5e6c1653c2497e7357cfb86</url>
  <id>2dcb0fc431f93b04d5e6c1653c2497e7357cfb86</id>
  <committed-date>2009-07-05T04:17:53-07:00</committed-date>
  <authored-date>2009-07-05T04:17:53-07:00</authored-date>
  <message>When coercing controller params, append missing params to list rather than raising an error &#8212; it will be left to the controller to examing the list and raise whatever error it wants. Additionally add some more specs to test more complex publish declarations.</message>
  <tree>84d4ba2a06eb85c200b37eb305a23950b1a0e3d7</tree>
  <committer>
    <name>Luke Sutton</name>
    <email>luke.sutton@gmail.com</email>
  </committer>
</commit>
