module R2OAS::Schema::V3::FromFiles::DeepMethods

Public Instance Methods

deep_replace!(data, target) { |value| ... } click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/deep_methods.rb, line 8
def deep_replace!(data, target, &blk)
  return unless data.is_a?(Hash)

  data.each do |key, value|
    if key.eql? target
      # MEMO:
      # When using the same schema, it has already been replaced by an object
      if value.is_a?(String)
        data[key] = block_given? ? yield(value) : value
      end
    else
      deep_replace!(value, target, &blk)
    end
  end
end