Sha256: 721e39f6c7497cd4ca55464065c841e23336c541180578298b4c9c806964fe68
Contents?: true
Size: 1.13 KB
Versions: 17
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Extension module Messages module MessageLoading def self.load type_specific_messages = load_current_type_messages return Messages::MESSAGES if type_specific_messages.nil? if type_specific_messages.key?(:overrides) deep_merge(Messages::MESSAGES, type_specific_messages[:overrides]) else Messages::MESSAGES end end def self.load_current_type_messages return unless ShopifyCli::Project.has_current? messages_for_type( ShopifyCli::Project.current.config[Extension::ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY] ) end def self.messages_for_type(type_identifier) return if type_identifier.nil? type_identifier_symbol = type_identifier.downcase.to_sym return unless Messages::TYPES.key?(type_identifier_symbol) TYPES[type_identifier_symbol] end def self.deep_merge(first, second) merger = proc { |_key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } first.merge(second, &merger) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems