Simple roles to include in your classes
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.document
.gitignore
LICENSE
README.rdoc
Rakefile

README.rdoc

simple_roles

Simple roles for your classes. Heavily based on Pat Nakajima's Roleful (github.com/nakajima/roleful), but with less features and less metaprogramming.

Basically just what I needed for a personal project, plus some additions I need (TODO).

Usage

class User
  include SimpleRoles

  def role
    :basic
  end

  role :basic do
    can :do_this
    can :do_that do |that|
      self == that
    end
  end

  role :advanced do
    can :do_advanced_stuff
  end
end

user = User.new

user.can?(:do_this) # => true
user.can?(:do_advanced_suff) # => false
user.can?(:do_that, 'I am not a user') # => false
user.can?(:do_that, user) # => true

Copyright

Copyright © 2009 Ismael Celis. See LICENSE for details.