Sha256: 6effe22b983b3ff738bb5cf07a577ea489ebb74091e3a69f6f69d166d1b45b80

Contents?: true

Size: 633 Bytes

Versions: 6

Compression:

Stored size: 633 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 = tags.map do |tag|
      SpudRolePermission.new(spud_permission_tag: tag)
    end
  end

  def permission_tags
    return self.permissions.collect(&:tag)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tb_core-1.5.4 app/models/spud_role.rb
tb_core-1.5.3 app/models/spud_role.rb
tb_core-1.5.2 app/models/spud_role.rb
tb_core-1.5.1 app/models/spud_role.rb
tb_core-1.5.0 app/models/spud_role.rb
tb_core-1.4.8 app/models/spud_role.rb