class PIM::ItemScopesAttributeFilter
Constants
- MATCH_TYPES
- PERMISSION_TYPES
Public Class Methods
create(match, allow: nil, deny: nil)
click to toggle source
# File pim.rb, line 11140 def self.create match, allow: nil, deny: nil match = ValueFilter.create(match, types: MATCH_TYPES) allow = ValueFilter.create(allow, types: PERMISSION_TYPES) unless allow.nil? deny = ValueFilter.create(deny, types: PERMISSION_TYPES) unless deny.nil? self.new(match: match, allow: allow, deny: deny) end
Public Instance Methods
as_json()
click to toggle source
# File pim.rb, line 11175 def as_json PIM::Utils.camelize(self.to_h.filter { |k,v| !v.nil? }) end
matches?(attribute, scope)
click to toggle source
# File pim.rb, line 11154 def matches? attribute, scope # The 'nil' scope matches always! return true if scope.nil? # Cannot decide, if attributes does not match return nil unless match.matches?(attribute) # Explicitly allow, if scopes matches allow allows = allow.matches?(scope) unless allow.nil? return true if allows == true # Explicitly deny, if scope matches deny denies = deny.matches?(scope) unless deny.nil? return false if denies == true # Cannot decide, if scope does not match return nil end
to_json(*args)
click to toggle source
# File pim.rb, line 11179 def to_json *args as_json.to_json(*args) end