mm-friendable¶ ↑
A simple MongoMapper plugin to add friendship functionality to your application
v1.1 is a mongomapper 0.9.0 update to support the new plugin system if you are using mongomapper 0.8.x please use version 1.0.1 of the gem
Usage¶ ↑
Install the gem
gem install mm-friendable
Or add it to your Gemfile
gem 'mm-friendable'
Then add the friendable plugin to you MongoMapper::Document
class User include MongoMapper::Document plugin MongoMapper::Plugins::Friendable def on_add_friend(friend) do something when a friend is added... end def on_remove_friend(friend) do something when a friend is removed... end end
You must implement the on_add_friend and on_remove_friend callbacks! - however they can be empty implementations
@user_1 = User.create @user_2 = User.create @user_1.add_friend!(@user_2) @user_1.following_count #=> 1 @user_1.following #=> [<User>] @user_1.following.first == @user_2 #=> true @user_2.followers_count #=> 1 @user_2.followers #=> [<User>] @user_2.followers.first == @user_1 #=> true @user_1.following(@user_2) #=> true @user_2.following(@user_1) #=> false
Contributing to mm-friendable¶ ↑
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright¶ ↑
Copyright © 2010 Luke Cunningham. See LICENSE.txt for further details.