Sha256: 5b3e301e5ed1704bf0bed8a71a0b6f6b17711592e067e61d6c47c300ffbc6712
Contents?: true
Size: 739 Bytes
Versions: 1
Compression:
Stored size: 739 Bytes
Contents
module GraphQL module DefinitionHelpers # Accepts a hash with symbol keys. # - convert keys to strings # - if the value responds to `name=`, then assign the hash key as `name` # # Used by {ObjectType#fields}, {Field#arguments} and others. class StringNamedHash # Normalized hash for the input # @return [Hash] Hash with string keys attr_reader :to_h # @param input_hash [Hash] Hash to be normalized def initialize(input_hash) @to_h = input_hash .reduce({}) { |memo, (key, value)| memo[key.to_s] = value; memo } # Set the name of the value based on its key @to_h.each {|k, v| v.respond_to?("name=") && v.name = k } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.11.1 | lib/graphql/definition_helpers/string_named_hash.rb |