Sha256: f30b3b7672adfd99f1059d1f19344356c1ba4f40c5f11523a7889edca0de70e3
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
# Roleplay Add support for 'roles' to Ruby classes ## Installation Add this line to your application's Gemfile: gem 'roleplay' And then execute: $ bundle Or install it yourself as: $ gem install roleplay ## Usage Create a folder anywhere in the app directory (ex. app/roles/) Create modules of similar methods that define roles (ex. Buyer, Seller might be roles) Set up the model: class User < ActiveRecord::Base has_role :buyer, using: Buyer has_role :seller, using: [Seller, Payable] end Now, instead of User.new, you can use User.new_with_role(:buyer) to create an instance that includes only the modules specified in the role definition. If you already have an instance, user.playing(:buyer) or user.as_a(:buyer) will both return duped instances with the requested modules included. Adding a bang will modify the original instance. ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roleplay-0.0.3 | README.md |