Cross Reference: permission.rb
xref
: /
ontohub
/
app
/
models
/
permission.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
permission.rb revision 0e96fcb3650434da3e94d65e8a6e481253b26cd7
class
Permission
<
ActiveRecord
::
Base
ROLES
= %w
(
owner
editor
)
# thrown if the last
admin
/
owner
tries to remove itself
class
PowerVaccuumError
<
Exception
;
end
attr_accessible
:
subject
, :
subject_id
, :
subject_type
, :
role
belongs_to
:
subject
, :
polymorphic
=>
true
belongs_to
:
item
, :
polymorphic
=>
true
validates_inclusion_of
:
role
, :
in
=>
ROLES
scope
:
item
, ->
(
item
)
{
where
\
item_id
:
item.id
,
item_type
:
item.class.to
_s
}
scope
:
subject
, ->
(
subject
)
{
where
\
subject_id
:
subject.id
,
subject_type
:
subject.class.to
_s
}
end