Class: SpudRole

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spud_role.rb

Instance Method Summary collapse

Instance Method Details

#permission_tagsObject



27
28
29
# File 'app/models/spud_role.rb', line 27

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

#permission_tags=(tags) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'app/models/spud_role.rb', line 16

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

#permissionsObject



8
9
10
# File 'app/models/spud_role.rb', line 8

def permissions
  self.spud_role_permissions.collect(&:permission).reject(&:blank?)
end

#permissions=(permissions_list) ⇒ Object



12
13
14
# File 'app/models/spud_role.rb', line 12

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