Sha256: 65548f694883de0aeaa79be80acff259f0a108f802b2fca492d8bd0b5888ea08
Contents?: true
Size: 930 Bytes
Versions: 7
Compression:
Stored size: 930 Bytes
Contents
# frozen_string_literal: true require "dry/initializer" require "dry/equalizer" require "dry/schema/constants" module Dry module Schema module Messages # @api private class Template extend Dry::Initializer include Dry::Equalizer(:messages, :key, :options) option :messages option :key option :options # @api private def data(data = EMPTY_HASH) ensure_message! messages.interpolatable_data(key, options, **options, **data) end # @api private def call(data = EMPTY_HASH) ensure_message! messages.interpolate(key, options, **data) end alias_method :[], :call private def ensure_message! return if messages.key?(key, options) raise KeyError, "No message found for template, template=#{inspect}" end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems