<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/unit/operator_resize_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -30,8 +30,15 @@ module Fleximage
       class_name = method_name.to_s.camelcase
       operator_class = &quot;Fleximage::Operator::#{class_name}&quot;.constantize
       
-      # Execute the operator
-      @image = operator_class.new(self, @image, @model).execute(*args)
+      # Define a method for this operator so future calls to this operation are faster
+      self.class.module_eval &lt;&lt;-EOF
+        def #{method_name}(*args)
+          @image = execute_operator(#{operator_class}, *args)
+        end
+      EOF
+      
+      # Call the method that was just defined to perform its functionality.
+      send(method_name, *args)
     
     rescue NameError =&gt; e
       if e.to_s =~ /uninitialized constant Fleximage::Operator::#{class_name}/
@@ -40,6 +47,13 @@ module Fleximage
         raise e
       end
     end
+    
+    private
+      # Instantiate and execute the requested image Operator.
+      def execute_operator(operator_class, *args)
+        operator_class.new(self, @image, @model).execute(*args)
+      end
+    
   end
   
 end
\ No newline at end of file</diff>
      <filename>lib/fleximage/image_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -315,8 +315,11 @@ module Fleximage
       # processed output image.
       def load_image #:nodoc:
         @output_image ||= @uploaded_image
+        
+        # Return the current image if we have loaded it already
         return @output_image if @output_image
         
+        # Load the image from disk
         if self.class.db_store?
           if image_file_data &amp;&amp; image_file_data.any?
             @output_image = Magick::Image.from_blob(image_file_data).first
@@ -447,7 +450,7 @@ module Fleximage
           
           # No default, not master image, so raise exception
           else
-            message = &quot;Master image was not found for this record, so no image can be rendered.&quot;
+            message = &quot;Master image was not found for this record&quot;
             
             if !self.class.db_store?
               message &lt;&lt; &quot;\nExpected image to be at:&quot;</diff>
      <filename>lib/fleximage/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,13 +29,16 @@ module Fleximage
       
       # Start the operation
       def execute(*args) #:nodoc:
+        # Get the result of the Operators #operate method
         result = operate(*args)
         
+        # Ensure that the result is an RMagick:Image object
         unless result.is_a?(Magick::Image)
           raise BadOperatorResult, &quot;expected #{self.class}#operate to return an instance of Magick::Image. \n&quot;+
                                    &quot;Got instance of #{result.class} instead.&quot;
         end
         
+        # Save the result to the operator proxy
         @proxy.image = result
       end
       
@@ -60,38 +63,42 @@ module Fleximage
       #
       #   x, y = size_to_xy(&quot;10x20&quot;)
       def size_to_xy(size)
-        if size.is_a?(Array) &amp;&amp; size.size == 2
+        case          
+        when size.is_a?(Array) &amp;&amp; size.size == 2  # [320, 240]
           size
-        elsif size.to_s.include?('x')
+      
+        when size.to_s.include?('x')              # &quot;320x240&quot;
           size.split('x').collect(&amp;:to_i)
-        else
+        
+        else # Anything else, convert the object to an integer and assume square dimensions
           [size.to_i, size.to_i]
+          
         end
       end
       
       # Scale the image, respecting aspect ratio.  
       # Operation will happen in the main &lt;tt&gt;@image&lt;/tt&gt; unless you supply the +img+ argument
       # to operate on instead.
-      def scale(size, img = nil)
-        (img || @image).change_geometry!(size_to_xy(size).join('x')) do |cols, rows, img|
+      def scale(size, img = @image)
+        img.change_geometry!(size_to_xy(size).join('x')) do |cols, rows, _img|
           cols = 1 if cols &lt; 1
           rows = 1 if rows &lt; 1
-          img.resize!(cols, rows)
+          _img.resize!(cols, rows)
         end
       end
       
       # Scale to the desired size and crop edges off to get the exact dimensions needed.
       # Operation will happen in the main &lt;tt&gt;@image&lt;/tt&gt; unless you supply the +img+ argument
       # to operate on instead.
-      def scale_and_crop(size, img = nil)
-        (img || @image).crop_resized!(*size_to_xy(size))
+      def scale_and_crop(size, img = @image)
+        img.crop_resized!(*size_to_xy(size))
       end
       
       # Resize the image, with no respect to aspect ratio.  
       # Operation will happen in the main &lt;tt&gt;@image&lt;/tt&gt; unless you supply the +img+ argument
       # to operate on instead.
-      def stretch(size, img = nil)
-        (img || @image).resize!(*size_to_xy(size))
+      def stretch(size, img = @image)
+        img.resize!(*size_to_xy(size))
       end
       
       # Convert a symbol to an RMagick blending mode.</diff>
      <filename>lib/fleximage/operator/base.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>81e51e7489ee4e397574a624d0eea432c675677d</id>
    </parent>
  </parents>
  <author>
    <name>Alex Wayne</name>
    <email>alex@beautifulpixel.com</email>
  </author>
  <url>http://github.com/Squeegy/fleximage/commit/58fd79dcf816d9417e2c78914fd02f2de5f74d3a</url>
  <id>58fd79dcf816d9417e2c78914fd02f2de5f74d3a</id>
  <committed-date>2008-05-21T13:06:00-07:00</committed-date>
  <authored-date>2008-05-21T13:06:00-07:00</authored-date>
  <message>ImageProxy#method_missing no longer directly executes operators.  Instead, it defines a method for that operator, then immediately calls that method.  Future calls for that operator are now handled by the ruby method, not method missing.  This keeps the dynamic ruby metaprogramming mumbo jumbo to only the first time you call an operator, and from then on its as as fast as calling a standard ruby method.</message>
  <tree>3a7d69b06106d9e5e7366a7c5c71a17647c4de34</tree>
  <committer>
    <name>Alex Wayne</name>
    <email>alex@beautifulpixel.com</email>
  </committer>
</commit>
