<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,7 +3,8 @@ class ActsAsFollowerMigration &lt; ActiveRecord::Migration
     create_table :follows, :force =&gt; true do |t|
       t.references :followable, :polymorphic =&gt; true, :null =&gt; false
       t.references :follower,   :polymorphic =&gt; true, :null =&gt; false
-      t.timestamps      
+      t.boolean :blocked, :default =&gt; false, :null =&gt; false
+      t.timestamps
     end
 
     add_index :follows, [&quot;follower_id&quot;, &quot;follower_type&quot;],     :name =&gt; &quot;fk_follows&quot;</diff>
      <filename>generators/acts_as_follower_migration/templates/migration.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,21 +23,53 @@ module ActiveRecord #:nodoc:
         
         # Returns the number of followers a record has.
         def followers_count
-          self.followings.count
+          self.followings.unblocked.count
+        end
+        
+        def blocked_followers_count
+          self.followings.blocked.count
         end
         
         # Returns the following records.
         def followers
-          self.followings.all(:include =&gt; [:follower]).collect {|f| f.follower }
+          self.followings.unblocked.all(:include =&gt; [:follower]).collect{|f| f.follower}
+        end
+        
+        def blocks
+          self.followings.blocked.all(:include =&gt; [:follower]).collect{|f| f.follower}
         end
         
-        # Returns true if the current instance is followed by the passed record.
+        # Returns true if the current instance is followed by the passed record
+        # Returns false if the current instance is blocked by the passed record or no follow is found
         def followed_by?(follower)
-          Follow.find(:first, :conditions =&gt; [&quot;followable_id = ? AND followable_type = ? AND follower_id = ? AND follower_type = ?&quot;, self.id, parent_class_name(self), follower.id, parent_class_name(follower)]) ? true : false
+          f = get_follow_for(follower)
+          (f &amp;&amp; !f.blocked?) ? true : false
+        end
+        
+        def block(follower)
+          get_follow_for(follower) ? block_existing_follow(follower) : block_future_follow(follower)
+        end
+        
+        def unblock(follower)
+          get_follow_for(follower).try(:delete)
+        end
+        
+        private
+        
+        def get_follow_for(follower)
+          Follow.find(:first, :conditions =&gt; [&quot;followable_id = ? AND followable_type = ? AND follower_id = ? AND follower_type = ?&quot;, self.id, parent_class_name(self), follower.id, parent_class_name(follower)])
         end
+        
+        def block_future_follow(follower)
+          follows.create(:followable =&gt; self, :follower =&gt; follower, :blocked =&gt; true)
+        end
+        
+        def block_existing_follow(follower)
+          get_follow_for(follower).block!
+        end
         
       end
       
     end
   end
-end
+end</diff>
      <filename>lib/acts_as_followable.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ module ActiveRecord #:nodoc:
         
         # Returns true if this instance is following the object passed as an argument.
         def following?(followable)
-          0 &lt; Follow.count(:all, :conditions =&gt; [
+          0 &lt; Follow.unblocked.count(:all, :conditions =&gt; [
                 &quot;follower_id = ? AND follower_type = ? AND followable_id = ? AND followable_type = ?&quot;,
                  self.id, parent_class_name(self), followable.id, parent_class_name(followable)
                ])
@@ -30,7 +30,7 @@ module ActiveRecord #:nodoc:
         
         # Returns the number of objects this instance is following.
         def follow_count
-          Follow.count(:all, :conditions =&gt; [&quot;follower_id = ? AND follower_type = ?&quot;, self.id, parent_class_name(self)])
+          Follow.unblocked.count(:all, :conditions =&gt; [&quot;follower_id = ? AND follower_type = ?&quot;, self.id, parent_class_name(self)])
         end
         
         # Creates a new follow record for this instance to follow the passed object.
@@ -52,12 +52,12 @@ module ActiveRecord #:nodoc:
         
         # Returns the follow records related to this instance by type.
         def follows_by_type(followable_type)
-          Follow.find(:all, :include =&gt; [:followable], :conditions =&gt; [&quot;follower_id = ? AND follower_type = ? AND followable_type = ?&quot;, self.id, parent_class_name(self), followable_type])
+          Follow.unblocked.find(:all, :include =&gt; [:followable], :conditions =&gt; [&quot;follower_id = ? AND follower_type = ? AND followable_type = ?&quot;, self.id, parent_class_name(self), followable_type])
         end
         
         # Returns the follow records related to this instance with the followable included.
         def all_follows
-          self.follows.all(:include =&gt; :followable)
+          self.follows.unblocked.all(:include =&gt; :followable)
         end
         
         # Returns the actual records which this instance is following.
@@ -84,7 +84,7 @@ module ActiveRecord #:nodoc:
         
         # Returns a follow record for the current instance and followable object.
         def get_follow(followable)
-          Follow.find(:first, :conditions =&gt; [&quot;follower_id = ? AND follower_type = ? AND followable_id = ? AND followable_type = ?&quot;, self.id, parent_class_name(self), followable.id, parent_class_name(followable)])
+          Follow.unblocked.find(:first, :conditions =&gt; [&quot;follower_id = ? AND follower_type = ? AND followable_id = ? AND followable_type = ?&quot;, self.id, parent_class_name(self), followable.id, parent_class_name(followable)])
         end
         
       end</diff>
      <filename>lib/acts_as_follower.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,16 @@ class Follow &lt; ActiveRecord::Base
   named_scope :for_followable, lambda { |*args| {:conditions =&gt; [&quot;followable_id = ? AND followable_type = ?&quot;, args.first.id, args.first.type.name]} }
   named_scope :recent,       lambda { |*args| {:conditions =&gt; [&quot;created_at &gt; ?&quot;, (args.first || 2.weeks.ago).to_s(:db)]} }
   named_scope :descending, :order =&gt; &quot;created_at DESC&quot;
+  named_scope :unblocked, :conditions =&gt; {:blocked =&gt; false}
+  named_scope :blocked, :conditions =&gt; {:blocked =&gt; true}
   
   # NOTE: Follows belong to the &quot;followable&quot; interface, and also to followers
   belongs_to :followable, :polymorphic =&gt; true
   belongs_to :follower,   :polymorphic =&gt; true
   
+  def block!
+    self.update_attribute(:blocked, true)
+  end
+  
 end
+</diff>
      <filename>lib/follow.rb</filename>
    </modified>
    <modified>
      <diff>@@ -71,7 +71,69 @@ class ActsAsFollowableTest &lt; Test::Unit::TestCase
       
       should_change(&quot;follow count&quot;, :by =&gt; -1) { Follow.count }
       should_change(&quot;@sam.all_following.size&quot;, :by =&gt; -1) { @sam.all_following.size }
-    end
+    end
+    
+    context &quot;blocking a follower&quot; do
+      setup do
+        @jon.block(@sam)
+      end
+      
+      should &quot;remove him from followers&quot; do
+        assert_equal 0, @jon.followers_count
+      end
+      
+      should &quot;add him to the blocked followers&quot; do
+        assert_equal 1, @jon.blocked_followers_count
+      end
+      
+      should &quot;not be able to follow again&quot; do
+        assert_equal 0, @jon.followers_count
+      end
+      
+      should &quot;not be present when listing followers&quot; do
+        assert_equal [], @jon.followers
+      end
+      
+      should &quot;be in the list of blocks&quot; do
+        assert_equal [@sam], @jon.blocks
+      end
+    end
+    
+    context &quot;unblocking a blocked follow&quot; do
+      setup do
+        @jon.block(@sam)
+        @jon.unblock(@sam)
+      end
+      
+      should &quot;not include the unblocked user in the list of followers&quot; do
+        assert_equal [], @jon.followers
+      end
+      
+      should &quot;remove him from the blocked followers&quot; do
+        assert_equal 0, @jon.blocked_followers_count
+        assert_equal [], @jon.blocks
+      end
+    end
+    
+    context &quot;unblock a non-existent follow&quot; do
+      setup do
+        @sam.stop_following(@jon)
+        @jon.unblock(@sam)
+      end
+      
+      should &quot;not be in the list of followers&quot; do
+        assert_equal [], @jon.followers
+      end
+      
+      should &quot;not be in the blockked followers count&quot; do
+        assert_equal 0, @jon.blocked_followers_count
+      end
+      
+      should &quot;not be in the blocks list&quot; do
+        assert_equal [], @jon.blocks
+      end
+    end
+    
   end
   
 end</diff>
      <filename>test/acts_as_followable_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -121,6 +121,29 @@ class ActsAsFollowerTest &lt; Test::Unit::TestCase
       
       should_change(&quot;Follow.count&quot;, :by =&gt; -1) { Follow.count }
       should_change(&quot;@sam.follow_count&quot;, :by =&gt; -1) { @sam.follow_count }
+    end
+    
+    context &quot;blocked by followable&quot; do
+      setup do
+        @jon.block(@sam)
+      end
+      
+      should &quot;return following_status&quot; do
+        assert_equal false, @sam.following?(@jon)
+      end
+      
+      should &quot;return follow_count&quot; do
+        assert_equal 1, @sam.follow_count
+      end
+      
+      should &quot;not return record of the blocked follows&quot; do
+        assert_equal 1, @sam.all_follows.size
+        assert !@sam.all_follows.include?(@user_follow)
+        assert !@sam.all_following.include?(@jon)
+        assert_equal [], @sam.following_by_type('User')
+        assert_equal [], @sam.follows_by_type('User')
+        assert_equal [], @sam.following_users
+      end
     end
   end
   </diff>
      <filename>test/acts_as_follower_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,7 @@ ActiveRecord::Schema.define :version =&gt; 0 do
     t.string   &quot;followable_type&quot;, :null =&gt; false
     t.integer  &quot;follower_id&quot;,     :null =&gt; false
     t.string   &quot;follower_type&quot;,   :null =&gt; false
+    t.boolean  &quot;blocked&quot;, :default =&gt; false, :null =&gt; false
     t.datetime &quot;created_at&quot;
     t.datetime &quot;updated_at&quot;
   end
@@ -17,4 +18,4 @@ ActiveRecord::Schema.define :version =&gt; 0 do
     t.column :name, :string
   end
   
-end
\ No newline at end of file
+end</diff>
      <filename>test/schema.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6307f0eb5d3371e85ccbf732f565de170ddc222b</id>
    </parent>
  </parents>
  <author>
    <name>Tom Cocca</name>
    <email>tom.cocca@gmail.com</email>
  </author>
  <url>http://github.com/tcocca/acts_as_follower/commit/112230742b1c8cea6e2f42496be5d95f7931fb3d</url>
  <id>112230742b1c8cea6e2f42496be5d95f7931fb3d</id>
  <committed-date>2009-11-08T16:37:08-08:00</committed-date>
  <authored-date>2009-11-08T16:37:08-08:00</authored-date>
  <message>Added the ability to block followers, unblocking a follower removes any record of the follow</message>
  <tree>98b464d6385fc5f1dcab6b9ae0f1e0efb20ce178</tree>
  <committer>
    <name>Tom Cocca</name>
    <email>tom.cocca@gmail.com</email>
  </committer>
</commit>
