Sha256: ad2a3540ceda1d655dfd4593172f24b209882286638bd717390c9e85f0616241
Contents?: true
Size: 792 Bytes
Versions: 45
Compression:
Stored size: 792 Bytes
Contents
module Avromatic module Model module Attribute # This subclass of Virtus::Attribute is defined to ensure that Avromatic # generated models (identified by their inclusion of # Avromatic::Model::Attributes) are always coerced by identifying an # instance of the model or creating a new one. # This is required to coerce models correctly with nested complex types # with Virtus. class Record < Virtus::Attribute primitive Avromatic::Model::Attributes def coerce(value) return value if value.nil? || value_coerced?(value) coerced = primitive.new(value) coerced if coerced.valid? end def value_coerced?(value) value.is_a?(primitive) end end end end end
Version data entries
45 entries across 45 versions & 1 rubygems