Sha256: 6f41384a143b2fddc3876889fd08319c27cf5624d227685274041d2647dcc97f

Contents?: true

Size: 789 Bytes

Versions: 8

Compression:

Stored size: 789 Bytes

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 < DetachedEntity::Casters::Hash
          def build_method(attributes)
            outcome = entity_class.attributes_type.process_value(attributes)

            outcome.result

            if outcome.success?
              :create
            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.
              :build
            end
          end

          def expected_type_symbol
            :entity
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foobara-0.0.38 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb
foobara-0.0.37 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb
foobara-0.0.36 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb
foobara-0.0.35 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb
foobara-0.0.34 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb
foobara-0.0.33 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb
foobara-0.0.32 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb
foobara-0.0.31 projects/entity/src/extensions/builtin_types/entity/casters/hash.rb