Sha256: 816f58035b44b462fb82b186d5f13af8ce1a30114ac47b53c8f3fac3ca725e5a
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module ImmutableStructExRedactable module RedactedAccessible class << self def included(base) base.extend ClassModules end end module ClassModules def redacted_accessible_module_for(hash:, config:) Module.new do if config.whitelist.any? hash.each do |attr, _| next if config.whitelist.include? attr unredacted_attr_method = "unredacted_#{attr}" code = <<~CODE def #{unredacted_attr_method} "#{hash[attr]}" end private :#{unredacted_attr_method} CODE class_eval code end else config.blacklist.each do |attr| unredacted_attr_method = "unredacted_#{attr}" code = <<~CODE def #{unredacted_attr_method} "#{hash[attr]}" end private :#{unredacted_attr_method} CODE class_eval code end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems