Method: GraphQL::Schema::Validator#partial_format

Defined in:
lib/graphql/schema/validator.rb

#partial_format(string, substitutions) ⇒ Object

This is like String#%, but it supports the case that only some of string's values are present in substitutions



29
30
31
32
33
34
35
# File 'lib/graphql/schema/validator.rb', line 29

def partial_format(string, substitutions)
  substitutions.each do |key, value|
    sub_v = value.is_a?(String) ? value : value.to_s
    string = string.gsub("%{#{key}}", sub_v)
  end
  string
end