Class: Vellum::VellumVariable
- Inherits:
-
Object
- Object
- Vellum::VellumVariable
- Defined in:
- lib/vellum_ai/types/vellum_variable.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #default ⇒ Vellum::VellumValue readonly
- #extensions ⇒ Vellum::VellumVariableExtensions readonly
- #id ⇒ String readonly
- #key ⇒ String readonly
- #required ⇒ Boolean readonly
- #schema ⇒ Hash{String => Object} readonly
- #type ⇒ Vellum::VellumVariableType readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(id:, key:, type:, required: OMIT, default: OMIT, extensions: OMIT, schema: OMIT, additional_properties: nil) ⇒ Vellum::VellumVariable constructor
- #to_json ⇒ String
Constructor Details
#initialize(id:, key:, type:, required: OMIT, default: OMIT, extensions: OMIT, schema: OMIT, additional_properties: nil) ⇒ Vellum::VellumVariable
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 41 def initialize(id:, key:, type:, required: OMIT, default: OMIT, extensions: OMIT, schema: OMIT, additional_properties: nil) @id = id @key = key @type = type @required = required if required != OMIT @default = default if default != OMIT @extensions = extensions if extensions != OMIT @schema = schema if schema != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "key": key, "type": type, "required": required, "default": default, "extensions": extensions, "schema": schema }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
25 26 27 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 25 def additional_properties @additional_properties end |
#default ⇒ Vellum::VellumValue (readonly)
19 20 21 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 19 def default @default end |
#extensions ⇒ Vellum::VellumVariableExtensions (readonly)
21 22 23 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 21 def extensions @extensions end |
#id ⇒ String (readonly)
11 12 13 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 11 def id @id end |
#key ⇒ String (readonly)
13 14 15 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 13 def key @key end |
#required ⇒ Boolean (readonly)
17 18 19 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 17 def required @required end |
#schema ⇒ Hash{String => Object} (readonly)
23 24 25 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 23 def schema @schema end |
#type ⇒ Vellum::VellumVariableType (readonly)
15 16 17 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 15 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::VellumVariable
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 58 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] key = parsed_json["key"] type = parsed_json["type"] required = parsed_json["required"] unless parsed_json["default"].nil? default = parsed_json["default"].to_json default = Vellum::VellumValue.from_json(json_object: default) else default = nil end unless parsed_json["extensions"].nil? extensions = parsed_json["extensions"].to_json extensions = Vellum::VellumVariableExtensions.from_json(json_object: extensions) else extensions = nil end schema = parsed_json["schema"] new( id: id, key: key, type: type, required: required, default: default, extensions: extensions, schema: schema, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
101 102 103 104 105 106 107 108 109 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 101 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.") obj.type.is_a?(Vellum::VellumVariableType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.required&.is_a?(Boolean) != false || raise("Passed value for field obj.required is not the expected type, validation failed.") obj.default.nil? || Vellum::VellumValue.validate_raw(obj: obj.default) obj.extensions.nil? || Vellum::VellumVariableExtensions.validate_raw(obj: obj.extensions) obj.schema&.is_a?(Hash) != false || raise("Passed value for field obj.schema is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
92 93 94 |
# File 'lib/vellum_ai/types/vellum_variable.rb', line 92 def to_json @_field_set&.to_json end |