Sha256: 98fc5957eed3bf688f6ac00d9619c3fc26845e7c017ab1c9a3314325833577f5
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# == Schema Information # # Table name: underworld_groups # # id :integer not null, primary key # name :string # role :string # created_at :datetime # updated_at :datetime # module Underworld # **Group** model for **Underworld** platform class Group < ORM.proper_base_class # Make this model authorizable include Concerns::Authorizable # Define **Group** fields if current ORM was **Mongoid** if ORM.mongoid? include Mongoid::Document include Mongoid::Timestamps field :name, type: String field :role, type: String end has_and_belongs_to_many :users, class_name: 'Underworld::User' has_and_belongs_to_many :permissions, class_name: 'Underworld::Permission' # Validations validates :name, presence: true validates :role, presence: true, uniqueness: true def self.policy_class GroupPolicy end def include_permission?(perm) if perm.is_a? Fixnum permission_ids.include? perm else permission_ids.include? perm.id end end def to_s name end private def permission_ids @permission_ids ||= permissions.map(&:id) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
underworld-1.0.0 | app/models/underworld/group.rb |