Sha256: 9eb4223e6ef621212aeb36df111d4025ee3d831abb03b9d785e73ba5a9723099
Contents?: true
Size: 1.17 KB
Versions: 5
Compression:
Stored size: 1.17 KB
Contents
# == Schema Information # # Table name: faalis_groups # # id :integer not null, primary key # name :string # role :string # created_at :datetime # updated_at :datetime # module Faalis # **Group** model for **Faalis** 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: 'Faalis::User' has_and_belongs_to_many :permissions, class_name: 'Faalis::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
5 entries across 5 versions & 1 rubygems