<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,6 @@
 == master
 
+* Allow dm-observer integration to be optional
 * Fix non-lambda callbacks not working for DataMapper/Sequel
 
 == 0.4.2 / 2008-12-28</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -332,6 +332,9 @@ callbacks, and observers.  For example,
     end
   end
 
+*Note* that the DataMapper::Observer integration is optional and only available
+when the dm-observer library is installed.
+
 For more information about the various behaviors added for DataMapper state
 machines, see StateMachine::Integrations::DataMapper.
 </diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,19 @@ module StateMachine
   module Integrations #:nodoc:
     # Adds support for integrating state machines with DataMapper resources.
     # 
+    # == Requirements
+    # 
+    # To use this feature of the DataMapper integration, the dm-observer library
+    # must be available.  This can be installed either directly or indirectly
+    # through dm-more.  When loading DataMapper, be sure to load the dm-observer
+    # library as well like so:
+    # 
+    #   require 'rubygems'
+    #   require 'dm-core'
+    #   require 'dm-observer'
+    # 
+    # If dm-observer is not available, then this feature will be skipped.
+    # 
     # == Examples
     # 
     # Below is an example of a simple state machine defined within a
@@ -153,7 +166,7 @@ module StateMachine
       
       # Loads additional files specific to DataMapper
       def self.extended(base) #:nodoc:
-        require 'state_machine/integrations/data_mapper/observer'
+        require 'state_machine/integrations/data_mapper/observer' if ::DataMapper.const_defined?('Observer')
       end
       
       # Runs a new database transaction, rolling back any changes if the</diff>
      <filename>lib/state_machine/integrations/data_mapper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,6 @@ begin
   # Load library
   require 'rubygems'
   require 'dm-core'
-  require 'dm-observer'
-  require 'dm-aggregates'
   
   # Establish database connection
   DataMapper.setup(:default, 'sqlite3::memory:')
@@ -123,7 +121,7 @@ begin
           false
         end
         
-        assert_equal 0, @resource.count
+        assert_equal 0, @resource.all.size
       end
       
       def test_should_not_rollback_transaction_if_true
@@ -132,7 +130,7 @@ begin
           true
         end
         
-        assert_equal 1, @resource.count
+        assert_equal 1, @resource.all.size
       end
       
       def test_should_not_override_the_column_reader
@@ -280,153 +278,159 @@ begin
       end
     end
     
-    class MachineWithObserversTest &lt; BaseTestCase
-      def setup
-        @resource = new_resource
-        @machine = StateMachine::Machine.new(@resource)
-        @record = @resource.new(:state =&gt; 'off')
-        @transition = StateMachine::Transition.new(@record, @machine, 'turn_on', 'off', 'on')
-      end
-      
-      def test_should_call_before_transition_callback_if_requirements_match
-        called = false
-        
-        observer = new_observer(@resource) do
-          before_transition :from =&gt; 'off' do
-            called = true
-          end
+    begin
+      require 'dm-observer'
+      
+      class MachineWithObserversTest &lt; BaseTestCase
+        def setup
+          @resource = new_resource
+          @machine = StateMachine::Machine.new(@resource)
+          @record = @resource.new(:state =&gt; 'off')
+          @transition = StateMachine::Transition.new(@record, @machine, 'turn_on', 'off', 'on')
         end
         
-        @transition.perform
-        assert called
-      end
-      
-      def test_should_not_call_before_transition_callback_if_requirements_do_not_match
-        called = false
-        
-        observer = new_observer(@resource) do
-          before_transition :from =&gt; 'on' do
-            called = true
+        def test_should_call_before_transition_callback_if_requirements_match
+          called = false
+          
+          observer = new_observer(@resource) do
+            before_transition :from =&gt; 'off' do
+              called = true
+            end
           end
+          
+          @transition.perform
+          assert called
         end
         
-        @transition.perform
-        assert !called
-      end
-      
-      def test_should_allow_targeting_specific_machine
-        @second_machine = StateMachine::Machine.new(@resource, :status)
-        
-        called_state = false
-        called_status = false
-        
-        observer = new_observer(@resource) do
-          before_transition :state, :from =&gt; 'off' do
-            called_state = true
-          end
+        def test_should_not_call_before_transition_callback_if_requirements_do_not_match
+          called = false
           
-          before_transition :status, :from =&gt; 'off' do
-            called_status = true
+          observer = new_observer(@resource) do
+            before_transition :from =&gt; 'on' do
+              called = true
+            end
           end
+          
+          @transition.perform
+          assert !called
         end
         
-        @transition.perform
-        
-        assert called_state
-        assert !called_status
-      end
-      
-      def test_should_pass_transition_to_before_callbacks
-        callback_args = nil
-        
-        observer = new_observer(@resource) do
-          before_transition do |*args|
-            callback_args = args
+        def test_should_allow_targeting_specific_machine
+          @second_machine = StateMachine::Machine.new(@resource, :status)
+          
+          called_state = false
+          called_status = false
+          
+          observer = new_observer(@resource) do
+            before_transition :state, :from =&gt; 'off' do
+              called_state = true
+            end
+            
+            before_transition :status, :from =&gt; 'off' do
+              called_status = true
+            end
           end
+          
+          @transition.perform
+          
+          assert called_state
+          assert !called_status
         end
         
-        @transition.perform
-        assert_equal [@transition], callback_args
-      end
-      
-      def test_should_call_after_transition_callback_if_requirements_match
-        called = false
-        
-        observer = new_observer(@resource) do
-          after_transition :from =&gt; 'off' do
-            called = true
+        def test_should_pass_transition_to_before_callbacks
+          callback_args = nil
+          
+          observer = new_observer(@resource) do
+            before_transition do |*args|
+              callback_args = args
+            end
           end
+          
+          @transition.perform
+          assert_equal [@transition], callback_args
         end
         
-        @transition.perform
-        assert called
-      end
-      
-      def test_should_not_call_after_transition_callback_if_requirements_do_not_match
-        called = false
-        
-        observer = new_observer(@resource) do
-          after_transition :from =&gt; 'on' do
-            called = true
+        def test_should_call_after_transition_callback_if_requirements_match
+          called = false
+          
+          observer = new_observer(@resource) do
+            after_transition :from =&gt; 'off' do
+              called = true
+            end
           end
+          
+          @transition.perform
+          assert called
         end
         
-        @transition.perform
-        assert !called
-      end
-      
-      def test_should_pass_transition_and_result_to_before_callbacks
-        callback_args = nil
-        
-        observer = new_observer(@resource) do
-          after_transition do |*args|
-            callback_args = args
+        def test_should_not_call_after_transition_callback_if_requirements_do_not_match
+          called = false
+          
+          observer = new_observer(@resource) do
+            after_transition :from =&gt; 'on' do
+              called = true
+            end
           end
+          
+          @transition.perform
+          assert !called
         end
         
-        @transition.perform
-        assert_equal [@transition, true], callback_args
-      end
-    end
-    
-    class MachineWithMixedCallbacksTest &lt; BaseTestCase
-      def setup
-        @resource = new_resource
-        @machine = StateMachine::Machine.new(@resource)
-        @record = @resource.new(:state =&gt; 'off')
-        @transition = StateMachine::Transition.new(@record, @machine, 'turn_on', 'off', 'on')
-        
-        @notifications = notifications = []
-        
-        # Create callbacks
-        @machine.before_transition(lambda {notifications &lt;&lt; :callback_before_transition})
-        @machine.after_transition(lambda {notifications &lt;&lt; :callback_after_transition})
-        
-        observer = new_observer(@resource) do
-          before_transition do
-            notifications &lt;&lt; :observer_before_transition
-          end
+        def test_should_pass_transition_and_result_to_before_callbacks
+          callback_args = nil
           
-          after_transition do
-            notifications &lt;&lt; :observer_after_transition
+          observer = new_observer(@resource) do
+            after_transition do |*args|
+              callback_args = args
+            end
           end
+          
+          @transition.perform
+          assert_equal [@transition, true], callback_args
         end
-        
-        @transition.perform
       end
       
-      def test_should_invoke_callbacks_in_specific_order
-        expected = [
-          :callback_before_transition,
-          :observer_before_transition,
-          :callback_after_transition,
-          :observer_after_transition
-        ]
+      class MachineWithMixedCallbacksTest &lt; BaseTestCase
+        def setup
+          @resource = new_resource
+          @machine = StateMachine::Machine.new(@resource)
+          @record = @resource.new(:state =&gt; 'off')
+          @transition = StateMachine::Transition.new(@record, @machine, 'turn_on', 'off', 'on')
+          
+          @notifications = notifications = []
+          
+          # Create callbacks
+          @machine.before_transition(lambda {notifications &lt;&lt; :callback_before_transition})
+          @machine.after_transition(lambda {notifications &lt;&lt; :callback_after_transition})
+          
+          observer = new_observer(@resource) do
+            before_transition do
+              notifications &lt;&lt; :observer_before_transition
+            end
+            
+            after_transition do
+              notifications &lt;&lt; :observer_after_transition
+            end
+          end
+          
+          @transition.perform
+        end
         
-        assert_equal expected, @notifications
+        def test_should_invoke_callbacks_in_specific_order
+          expected = [
+            :callback_before_transition,
+            :observer_before_transition,
+            :callback_after_transition,
+            :observer_after_transition
+          ]
+          
+          assert_equal expected, @notifications
+        end
       end
+    rescue LoadError
+      $stderr.puts 'Skipping DataMapper Observer tests. `gem install dm-observer` and try again.'
     end
   end
 rescue LoadError
-  $stderr.puts 'Skipping DataMapper tests. `gem install dm-core dm-observer dm-aggregates` and try again.'
+  $stderr.puts 'Skipping DataMapper Core tests. `gem install dm-core` and try again.'
 end</diff>
      <filename>test/unit/integrations/data_mapper_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>82a5135b1b6fc17f52ff63a1e462d73057498c2c</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </author>
  <url>http://github.com/pluginaweek/state_machine/commit/bae9e169137fb016016ebc1a9f3f36674f6504c0</url>
  <id>bae9e169137fb016016ebc1a9f3f36674f6504c0</id>
  <committed-date>2008-12-28T15:40:03-08:00</committed-date>
  <authored-date>2008-12-28T15:40:03-08:00</authored-date>
  <message>Allow dm-observer integration to be optional</message>
  <tree>aeaa9596a069b12d616f3eff95b3a8ad48d81e9e</tree>
  <committer>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </committer>
</commit>
