class PIM::Authorization::RoleBuilder

Attributes

data_model[R]

Public Class Methods

new(data_model, default_permissions) click to toggle source
# File pim.rb, line 8176
def initialize data_model, default_permissions
  @data_model = data_model
  @default_permissions = default_permissions
end

Public Instance Methods

allow(object_type = ALL, *actions, &block) click to toggle source
# File pim.rb, line 8195
def allow object_type = ALL, *actions, &block
  @permissions << AllowPermission.new(data_model, object_type, *actions, &block)
end
build(name, match_mode: DEFAULT_MATCH_MODE, default_permissions: true, &block) click to toggle source
# File pim.rb, line 8181
def build name, match_mode: DEFAULT_MATCH_MODE, default_permissions: true, &block
  @permissions = []
  # Skip the data-module's +default_permissions+ scaffolding when the
  # caller explicitly opts out via +default_permissions: false+. Used
  # for +match: :deny+ / +match: :any+ roles whose decisive deny/allow
  # would otherwise be shadowed by the prepended defaults (LAX-9663).
  # +@default_permissions+ (the +Proc+) and +default_permissions+ (the
  # boolean kwarg) are distinct names here - the +@+ sigil avoids the
  # shadowing the +role+ DSL method has to work around.
  self.instance_exec(&@default_permissions) if @default_permissions && default_permissions
  self.instance_exec(&block)
  Role.new(name, @permissions, match_mode: match_mode)
end
deny(object_type = ALL, *actions, &block) click to toggle source
# File pim.rb, line 8199
def deny object_type = ALL, *actions, &block
  @permissions << DenyPermission.new(data_model, object_type, *actions, &block)
end