Module: MongoMapper::Plugins::AuthorizedObject::ClassMethods

Defined in:
lib/rad/mongo_mapper/acts_as/authorized_object.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_authorized_objectObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/rad/mongo_mapper/acts_as/authorized_object.rb', line 6

def acts_as_authorized_object
  key :owner_name, String, :default => lambda{User.current? ? User.current.name : nil}, :protected => true
  key :collaborators, Array, :protected => true
  # Contains the role and all upper roles. So complex becouse we need it in indexes.
  key :viewers, Array, :default => lambda{User.current? ? ["user:#{User.current.name}", 'manager'].sort : ['manager']}, :protected => true
 
  validates_presence_of :owner_name
  validate :validate_viewers
  validate :validate_collaborators
end