Method: Authorize::ActiveRecord::ClassMethods#authorizable_trustee

Defined in:
lib/authorize/active_record.rb

#authorizable_trustee(options = {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/authorize/active_record.rb', line 8

def authorizable_trustee(options = {})
  include Authorize::Trustee
  # The "identity" role -the single role that represents this trustee.  It is also the root vertex for collecting
  # the set of roles belonging to the trustee.
  has_one :role, :class_name => "Authorize::Role", :as => :resource, :conditions => {:relation => nil}, :dependent => :destroy
  after_create {|trustee| trustee.create_role(:name => options[:name] || trustee.to_s)}
end