Sha256: 7bfa591ac5223f96ee9e8e835ee24f30f617bd3df5fa72c112342bd399a07c3b

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Alberich
  class Privilege < ActiveRecord::Base
    attr_accessible :action, :role, :role_id, :target_type

    PERM_SET  = "set_perms"    # can create/modify/delete permission
                               # records on this object
    PERM_VIEW = "view_perms"   # can view permission records on this
                               # object
    CREATE    = "create"       # can create objects of this type here
    MODIFY    = "modify"       # can modify objects of this type here
    VIEW      = "view"         # can view objects of this type here
    USE       = "use"          # can use objects of this type here

    ACTIONS = [ CREATE, MODIFY, USE, VIEW,
                PERM_SET, PERM_VIEW]
    TARGET_TYPES = ["Alberich::BasePermissionObject"] +
      Alberich.permissioned_object_classes +
      Alberich.additional_privilege_scopes

    belongs_to :role
    validates_presence_of :role_id
    validates_presence_of :target_type
    validates_presence_of :action
    validates_uniqueness_of :action, :scope => [:target_type, :role_id]
    validates_inclusion_of :target_type, :in => TARGET_TYPES
    validates_inclusion_of :action, :in => ACTIONS

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alberich-0.2.0 app/models/alberich/privilege.rb