Sha256: 008a73678ecb39131871ac59165c6eb7df8c7094eaadfcb591cad52e90c4e4c3

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

# Groupify [![Build Status](https://secure.travis-ci.org/dwbutler/groupify.png)](http://travis-ci.org/dwbutler/groupify)
Adds group and membership functionality to Rails models.

Currently only Mongoid is supported. Tested in Ruby 1.8.7 and 1.9.3.

## Installation

Add this line to your application's Gemfile:

    gem 'groupify'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install groupify

## Getting Started
In your group model:

```ruby
class Group
	include Mongoid::Document

	acts_as_group
end
```

In your user model:

```ruby
class User
	include Mongoid::Document
	
	acts_as_group_member
end
```

## Usage

Create groups and add members:

```ruby
group = Group.new
user = User.new

user.groups << group
or
group.add user

user.in_group?(group)	=> true
```

Add to named groups:

```ruby
user.groups << :admin
user.in_group?(:admin)	=> true
```

Check if two group members share any of the same groups:

```ruby
user1.shares_any_group?(user2)
```

Query for groups & members:

```ruby
User.in_group(group)	# Find all users in this group
Group.with_member(user)	# Find all groups with this user

User.shares_any_group(user)	# Find all users that share any groups with this user
User.shares_any_named_group(user)	# Find all users that share any named groups with this user
```

Check the specs for more details.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
groupify-0.2.1 README.md
groupify-0.2.0 README.md