class PIM::Authorization::Role

Attributes

hidden[R]
name[R]
permissions[R]

Public Class Methods

new(name, permissions) click to toggle source
# File pim.rb, line 7313
def initialize name, permissions
  @name = name
  @permissions = permissions
  @hidden = false
end

Public Instance Methods

as_json(opts = {}) click to toggle source
# File pim.rb, line 7319
def as_json opts = {}
  json = {
    :name => name,
    :permissions => permissions.map { |p| p.as_json(opts) },
    :hidden => hidden
  }
  json
end
get_matching_permissions(object_type, action, context = nil) click to toggle source
# File pim.rb, line 7335
def get_matching_permissions object_type, action, context = nil
  permissions = []
  @permissions.each do |p|
    permissions << p if p.matches?(object_type, action, context)
  end
  permissions
end
has_permission?(object_type, action, context = nil) click to toggle source
# File pim.rb, line 7328
def has_permission? object_type, action, context = nil
  @permissions.reverse_each do |p|
    return p.is_allowed? if p.matches?(object_type, action, context)
  end
  false
end
hide() click to toggle source
# File pim.rb, line 7343
def hide
  @hidden = true
end