Sha256: 8757c0f5980d3382663de4665f1338a2cdc334abcc7ce1e574bba761242d5835
Contents?: true
Size: 1.01 KB
Versions: 11
Compression:
Stored size: 1.01 KB
Contents
module Foobara module BuiltinTypes module Entity module Casters # TODO: We need a way of disabling/enabling this and it should probably be disabled by default. class Hash < Attributes::Casters::Hash class << self def requires_parent_declaration_data? true end end def cast(attributes) symbolized_attributes = super outcome = entity_class.attributes_type.process_value(symbolized_attributes) if outcome.success? entity_class.create(symbolized_attributes) else # we build an instance so that it can fail a validator later. But we already know we don't want to # persist this thing. So use build instead of create. entity_class.build(outcome.result) end end def entity_class Object.const_get(parent_declaration_data[:model_class]) end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems