Sha256: 5e76ccbf85424f658a65931db6fee832960e0322dba5fbab6e2ec359c99fa64d
Contents?: true
Size: 546 Bytes
Versions: 5
Compression:
Stored size: 546 Bytes
Contents
# frozen_string_literal: true module Openai101 module Types # Used by the ActiveModel attributes API to cast values to hashes class HashType < ActiveModel::Type::Value def cast(value) case value when String JSON.parse(value) when Hash value else raise ArgumentError, "Cannot cast #{value.class} to Hash" end end def serialize(value) value.to_json end end end end ActiveModel::Type.register(:hash, Openai101::Types::HashType)
Version data entries
5 entries across 5 versions & 1 rubygems