class PIM::ItemScopeAccess

Per-attribute overwrite of global item_scopes attribute_filter (allow/deny), optionally with the same Group/Collection filter_member rewrite as DirectPublication.

Constants

PERMISSION_TYPES
TYPES

Public Class Methods

create(allow: nil, deny: nil, filter_member: nil, filter_member_match_value: nil) click to toggle source
# File pim.rb, line 12524
def self.create allow: nil,
                deny: nil,
                filter_member: nil,
                filter_member_match_value: nil

  allow = ValueFilter.create(allow, types: PERMISSION_TYPES) unless allow.nil?
  deny = ValueFilter.create(deny, types: PERMISSION_TYPES) unless deny.nil?

  unless filter_member.nil?
    filter_member = filter_member.to_s
    raise "'filter_member' must be a non-empty String" if filter_member.empty?
  end

  raise "'filter_member_match_value' requires 'filter_member'" \
    if filter_member.nil? and !filter_member_match_value.nil?

  raise "'filter_member' requires 'filter_member_match_value'" \
    if !filter_member.nil? and filter_member_match_value.nil?

  filter_member_match_value =
    ValueFilter.create(filter_member_match_value, types: TYPES) unless filter_member_match_value.nil?

  self.new(allow: allow,
           deny: deny,
           filter_member: filter_member,
           filter_member_match_value: filter_member_match_value)

end

Public Instance Methods

as_json() click to toggle source
# File pim.rb, line 12568
def as_json
  PIM::Utils.camelize(self.to_h.filter { |k,v| !v.nil? })
end
matches_scopes?(scope) click to toggle source

Same allow-then-deny semantics as ItemScopesAttributeFilter, without an attribute match.

# File pim.rb, line 12554
def matches_scopes? scope

  return true if scope.nil?

  allows = allow.matches?(scope) unless allow.nil?
  return true if allows == true

  denies = deny.matches?(scope) unless deny.nil?
  return false if denies == true

  return nil

end
to_json(*args) click to toggle source
# File pim.rb, line 12572
def to_json *args
  as_json.to_json(*args)
end
verify(attribute) click to toggle source
# File pim.rb, line 12576
def verify attribute
  verify_filter_member(attribute) unless filter_member.nil?
end