Sha256: dfa11fbe772a401e8653f4d5e1e6a358a97270dc15c29240c4da49e1f1259b32
Contents?: true
Size: 935 Bytes
Versions: 2
Compression:
Stored size: 935 Bytes
Contents
# frozen_string_literal: true require 'immutable_struct_ex' require_relative 'immutable_struct_ex_redactable/configuration' require_relative 'immutable_struct_ex_redactable/redacted_accessible' require_relative 'immutable_struct_ex_redactable/version' module ImmutableStructExRedactable include RedactedAccessible module_function def create(**hash, &block) config = ImmutableStructExRedactable.configure create_with(config, **hash, &block) end def create_with(config, **hash, &block) if config.redacted_unsafe? redacted_private_accessible_module = redacted_accessible_module_for(hash: hash, config: config) end config.redacted.each do |attr| next unless hash.key? attr hash[attr] = config.redacted_label end ImmutableStructEx.new(**hash, &block).tap do |struct| struct.extend(redacted_private_accessible_module) if config.redacted_unsafe? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
immutable_struct_ex_redactable-1.2.1 | lib/immutable_struct_ex_redactable.rb |
immutable_struct_ex_redactable-1.2.0 | lib/immutable_struct_ex_redactable.rb |