Class: PackageProtections::Private::MetadataModifiers

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/package_protections/private/metadata_modifiers.rb

Class Method Summary collapse

Class Method Details

.package_with_modified_protection(package, protection_identifier, violation_behavior) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/package_protections/private/metadata_modifiers.rb', line 11

def self.package_with_modified_protection(package, protection_identifier, violation_behavior)
  # We dup this to prevent mutations to the original underlying hash
   = package..dup
  protections = ['protections'].dup || {}
  protections[protection_identifier] = violation_behavior.serialize
  ['protections'] = protections

  ParsePackwerk::Package.new(
    name: package.name,
    enforce_dependencies: package.enforce_dependencies,
    enforce_privacy: package.enforce_privacy,
    dependencies: package.dependencies,
    metadata: 
  )
end