Skip to content

Instantly share code, notes, and snippets.

@cameroncox
Forked from adam/authorization_user.rb
Created July 26, 2008 18:39
Show Gist options
  • Save cameroncox/2674 to your computer and use it in GitHub Desktop.
Save cameroncox/2674 to your computer and use it in GitHub Desktop.
module Authorization
module User
# include ::DataMapper::Resource
# This is a "vanity" relationship. A user may not have all permissions for an entire role,
# but still may be said to be a member of the role.
# has_and_belongs_to_many :roles
has 1.0/0, :roles, :through => ::DataMapper::Resource
# This relationship contains the actual list of permissions the user has been granted.
has 1.0/0, :permissions, :through => ::DataMapper::Resource
before :save, :assign_role
def revoke_role(role)
#...
end
class User
include DataMapper::Resource
include DataMapper::Timestamp
include Authorization::User
PAGE_SIZE = 150
ADMIN_PAGE_SIZE = 150
property :id, Serial
# .....
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment