Module: ImmutableStructExRedactable
- Includes:
- RedactedAccessible
- Defined in:
- lib/immutable_struct_ex_redactable/configuration.rb,
lib/immutable_struct_ex_redactable.rb,
lib/immutable_struct_ex_redactable/version.rb,
lib/immutable_struct_ex_redactable/redacted_accessible.rb
Overview
This is the configuration for ImmutableStructExRedactable.
Defined Under Namespace
Modules: RedactedAccessible Classes: Configuration
Constant Summary collapse
- VERSION =
'1.3.8'
Class Attribute Summary collapse
-
.configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Class Method Summary collapse
-
.configure {|configuration| ... } ⇒ Configuration
Returns the application configuration object.
- .create ⇒ Object
- .create_with(config, **hash, &block) ⇒ Object
Methods included from RedactedAccessible
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
6 7 8 |
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 6 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Configuration
Returns the application configuration object.
11 12 13 14 15 16 17 |
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 11 def configure self.configuration ||= Configuration.new yield(configuration) if block_given? configuration end |
.create ⇒ Object
13 14 15 16 |
# File 'lib/immutable_struct_ex_redactable.rb', line 13 def create(...) config = ImmutableStructExRedactable.configure create_with(config, ...) end |
.create_with(config, **hash, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/immutable_struct_ex_redactable.rb', line 18 def create_with(config, **hash, &block) if config.redacted_unsafe? redacted_private_accessible_module = redacted_accessible_module_for(hash: hash, config: config) end if config.whitelist.any? hash.each_key do |key| next if config.whitelist.include? key hash[key] = config.redacted_label end else config.blacklist.each do |attr| next unless hash.key? attr hash[attr] = config.redacted_label end end ImmutableStructEx.new(**hash, &block).tap do |struct| struct.extend(redacted_private_accessible_module) if config.redacted_unsafe? end end |