Sha256: f3762d0eaae1eab6c6fe686f673edd0f12414eb09bd9432ddc064941cbde32a8
Contents?: true
Size: 1.05 KB
Versions: 26
Compression:
Stored size: 1.05 KB
Contents
module Foobara module BuiltinTypes module Attributes module SupportedTransformers class Defaults < Value::Transformer class << self def requires_parent_declaration_data? true end end def transform(attributes_hash) to_apply = {} defaults.each_pair do |attribute_name, default| if attributes_hash.key?(attribute_name) value = attributes_hash[attribute_name] if value.nil? allow_nil = parent_declaration_data[:element_type_declarations][attribute_name][:allow_nil] unless allow_nil to_apply[attribute_name] = default end end else to_apply[attribute_name] = default end end if to_apply.empty? attributes_hash else attributes_hash.merge(to_apply) end end end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems