Sha256: 74f670b613a803e066e20815ecb70d0a3bdef04e73c325384641a7eae86ccd5f
Contents?: true
Size: 887 Bytes
Versions: 4
Compression:
Stored size: 887 Bytes
Contents
class SpudRole < ActiveRecord::Base has_many :spud_role_permissions, dependent: :destroy has_many :users, class_name: 'SpudUser', dependent: :nullify validates :name, presence: true, uniqueness: true def permissions self.spud_role_permissions.collect(&:permission).reject(&:blank?) end def permissions=(permissions_list) self.permission_tags = permissions_list.collect(&:tag) end def permission_tags=(tags) self.spud_role_permissions.each do |role_permission| if role_permission.permission.nil? || !tags.include?(role_permission.permission.tag) role_permission.destroy() else tags.delete(role_permission.permission.tag) end end self.spud_role_permissions += tags.collect{ |tag| SpudRolePermission.new(spud_permission_tag: tag) } end def permission_tags return self.permissions.collect(&:tag) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
tb_core-1.4.7 | app/models/spud_role.rb |
tb_core-1.4.6 | app/models/spud_role.rb |
tb_core-1.4.5 | app/models/spud_role.rb |
tb_core-1.4.4 | app/models/spud_role.rb |