29 lines
685 B
Ruby
29 lines
685 B
Ruby
|
class Role
|
||
|
|
||
|
include Mongoid::Document
|
||
|
include Mongoid::Timestamps
|
||
|
|
||
|
field :key
|
||
|
field :built_in, :type => Boolean, :default => false
|
||
|
field :disabled, :type => Boolean, :default => false
|
||
|
|
||
|
embeds_many :sub_roles
|
||
|
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||
|
has_many :users
|
||
|
accepts_nested_attributes_for :i18n_variable, :allow_destroy => true
|
||
|
accepts_nested_attributes_for :sub_roles, :allow_destroy => true
|
||
|
|
||
|
def is_built_in?
|
||
|
self.built_in
|
||
|
end
|
||
|
|
||
|
def is_disabled?
|
||
|
self.disabled
|
||
|
end
|
||
|
|
||
|
# Get an role from key
|
||
|
def self.get_role_from_key(key)
|
||
|
self.first(:conditions => {:key => key})
|
||
|
end
|
||
|
|
||
|
end
|