<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,8 +4,8 @@ module Clipper
 
       # A Clipper::TypeMap::Signature is used to convert to and from
       # values matching the types defined for it using the procedures
-      # passed to the +from_procedure+ and +to_procedure+ arguments.
-      def initialize(attribute_types, repository_types, from_procedure, to_procedure)
+      # passed to the +typecast_left_procedure+ and +typecast_right_procedure+ arguments.
+      def initialize(attribute_types, repository_types, typecast_left_procedure, typecast_right_procedure)
 
         unless attribute_types.is_a?(Array) &amp;&amp; attribute_types.all? { |type| type.is_a?(Class) }
           raise ArgumentError.new(
@@ -21,16 +21,51 @@ module Clipper
         end
         @repository_types = repository_types
 
-        unless from_procedure.respond_to?(:call)
-          raise ArgumentError.new(&quot;#{self.class}:from_procedure must respond to :call&quot;)
+        unless typecast_left_procedure.respond_to?(:call)
+          raise ArgumentError.new(&quot;#{self.class}:typecast_left_procedure must respond to :call&quot;)
         end
-        @from_procedure = from_procedure
+        @typecast_left_procedure = typecast_left_procedure
 
-        unless to_procedure.respond_to?(:call)
-          raise ArgumentError.new(&quot;#{self.class}:to_procedure must respond to :call&quot;)
+        unless typecast_right_procedure.respond_to?(:call)
+          raise ArgumentError.new(&quot;#{self.class}:typecast_right_procedure must respond to :call&quot;)
         end
-        @to_procedure = to_procedure
+        @typecast_right_procedure = typecast_right_procedure
       end
-    end
-  end
-end
\ No newline at end of file
+
+      def match?(attribute_types, repository_types)
+        attribute_types == @attribute_types &amp;&amp; repository_types == @repository_types
+      end
+
+      def typecast_left(*args)
+        matching_types = true
+        @repository_types.each_with_index do |type, i|
+          unless args[i] == nil || args[i].is_a?(type)
+            matching_types = false
+            break
+          end
+        end
+
+        unless matching_types
+          raise ArgumentError.new(&quot;Expected args to be instances of #{@repository_types.inspect} but was #{args.inspect}.&quot;)
+        end
+
+        @typecast_left_procedure.call(*args)
+      end
+
+      def typecast_right(*args)
+        matching_types = true
+        @attribute_types.each_with_index do |type, i|
+          unless args[i] == nil || args[i].is_a?(type)
+            matching_types = false
+            break
+          end
+        end
+
+        unless matching_types
+          raise ArgumentError.new(&quot;Expected args to be instances of #{@attribute_types.inspect} but was #{args.inspect}.&quot;)
+        end
+        @typecast_right_procedure.call(*args)
+      end
+    end # class Signature
+  end # class TypeMap
+end # module Clipper
\ No newline at end of file</diff>
      <filename>lib/clipper/type_map/signature.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,16 +3,18 @@ require Pathname(__FILE__).dirname.parent + &quot;helper&quot;
 
 class SignatureTest &lt; Test::Unit::TestCase
 
-  def test_types_must_be_arrays_containing_classes
+  def test_a_well_formed_signature
     assert_nothing_raised do
       Clipper::TypeMap::Signature.new(
         [String, String],   # Attribute Type(s)
         [Integer, Integer], # Repository Type(s)
-        lambda { },         # &quot;From&quot; (Attribute Type) Procedure
-        lambda { }          # &quot;To&quot; (Attribute Type) Procedure
+        lambda { },         # typecast_left_procedure (Repository to Attribute) Procedure
+        lambda { }          # typecast_right_procedure (Attribute to Repository) Procedure
       )
     end
+  end
 
+  def test_types_must_be_arrays_containing_classes
     assert_raises(ArgumentError) do
       Clipper::TypeMap::Signature.new(
         nil,
@@ -32,4 +34,68 @@ class SignatureTest &lt; Test::Unit::TestCase
     end
   end
 
+  def test_procedures_must_respond_to_call
+    assert_raises(ArgumentError) do
+      Clipper::TypeMap::Signature.new(
+        [String, String],
+        [Integer, Integer],
+        nil,
+        lambda { }
+      )
+    end
+
+    assert_nothing_raised do
+
+      conversion = Class.new do
+        def self.call(*args)
+          nil
+        end
+      end
+
+      Clipper::TypeMap::Signature.new(
+        [String, String],
+        [Integer, Integer],
+        conversion,
+        lambda { }
+      )
+    end
+  end
+
+  def test_matching
+    signature = Clipper::TypeMap::Signature.new(
+      [String, String],
+      [Integer, Integer],
+      lambda { },
+      lambda { }
+    )
+
+    assert(signature.match?([String, String], [Integer, Integer]))
+    assert(!signature.match?([String], [Integer, Integer]))
+    assert(!signature.match?(nil, nil))
+  end
+
+  def test_type_casting
+    typecast_left_procedure = lambda { |age| age.to_i }
+    typecast_right_procedure = lambda { |age| age.to_s }
+
+    signature = Clipper::TypeMap::Signature.new(
+      [String],
+      [Integer],
+      typecast_left_procedure,
+      typecast_right_procedure
+    )
+
+    assert_nothing_raised do
+      signature.typecast_left(2)
+    end
+
+    assert_nothing_raised do
+      signature.typecast_left(nil)
+    end
+
+    assert_raises(ArgumentError) do
+      signature.typecast_left(&quot;one&quot;)
+    end
+  end
+
 end
\ No newline at end of file</diff>
      <filename>tests/unit/signature_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>41a6e412c0c97a5ec1ad90c54fb59cf94459eb4c</id>
    </parent>
  </parents>
  <author>
    <name>Sam Smoot</name>
    <email>ssmoot@gmail.com</email>
  </author>
  <url>http://github.com/wiecklabs/clipper/commit/29868df954c126606e11f0cb8f905f3e19bdd6a8</url>
  <id>29868df954c126606e11f0cb8f905f3e19bdd6a8</id>
  <committed-date>2009-06-22T10:55:31-07:00</committed-date>
  <authored-date>2009-06-22T10:55:31-07:00</authored-date>
  <message>Fleshed out the Signature API a bit more, added some type-checking to typecast_left and typecast_right.</message>
  <tree>320644d91a0490ce998018272eee7a2eea2cf578</tree>
  <committer>
    <name>Sam Smoot</name>
    <email>ssmoot@gmail.com</email>
  </committer>
</commit>
