Class: Vellum::MetadataFilterRuleRequest
- Inherits:
-
Object
- Object
- Vellum::MetadataFilterRuleRequest
- Defined in:
- lib/vellum_ai/types/metadata_filter_rule_request.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#combinator ⇒ Object
readonly
Returns the value of attribute combinator.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#negated ⇒ Object
readonly
Returns the value of attribute negated.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ MetadataFilterRuleRequest
Deserialize a JSON object to an instance of MetadataFilterRuleRequest.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(combinator: nil, negated: nil, rules: nil, field: nil, operator: nil, value: nil, additional_properties: nil) ⇒ MetadataFilterRuleRequest constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of MetadataFilterRuleRequest to a JSON object.
Constructor Details
#initialize(combinator: nil, negated: nil, rules: nil, field: nil, operator: nil, value: nil, additional_properties: nil) ⇒ MetadataFilterRuleRequest
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 19 def initialize(combinator: nil, negated: nil, rules: nil, field: nil, operator: nil, value: nil, additional_properties: nil) # @type [METADATA_FILTER_RULE_COMBINATOR] @combinator = combinator # @type [Boolean] @negated = negated # @type [Array<MetadataFilterRuleRequest>] @rules = rules # @type [String] @field = field # @type [LOGICAL_OPERATOR] @operator = operator # @type [String] @value = value # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9 def additional_properties @additional_properties end |
#combinator ⇒ Object (readonly)
Returns the value of attribute combinator.
9 10 11 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9 def combinator @combinator end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
9 10 11 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9 def field @field end |
#negated ⇒ Object (readonly)
Returns the value of attribute negated.
9 10 11 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9 def negated @negated end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
9 10 11 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9 def operator @operator end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
9 10 11 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9 def rules @rules end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 9 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ MetadataFilterRuleRequest
Deserialize a JSON object to an instance of MetadataFilterRuleRequest
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) combinator = METADATA_FILTER_RULE_COMBINATOR.key(parsed_json["combinator"]) || parsed_json["combinator"] negated = struct.negated rules = parsed_json["rules"].map do |v| v = v.to_json MetadataFilterRuleRequest.from_json(json_object: v) end field = struct.field operator = LOGICAL_OPERATOR.key(parsed_json["operator"]) || parsed_json["operator"] value = struct.value new(combinator: combinator, negated: negated, rules: rules, field: field, operator: operator, value: value, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
75 76 77 78 79 80 81 82 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 75 def self.validate_raw(obj:) obj.combinator&.is_a?(METADATA_FILTER_RULE_COMBINATOR) != false || raise("Passed value for field obj.combinator is not the expected type, validation failed.") obj.negated&.is_a?(Boolean) != false || raise("Passed value for field obj.negated is not the expected type, validation failed.") obj.rules&.is_a?(Array) != false || raise("Passed value for field obj.rules is not the expected type, validation failed.") obj.field&.is_a?(String) != false || raise("Passed value for field obj.field is not the expected type, validation failed.") obj.operator&.is_a?(LOGICAL_OPERATOR) != false || raise("Passed value for field obj.operator is not the expected type, validation failed.") obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of MetadataFilterRuleRequest to a JSON object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vellum_ai/types/metadata_filter_rule_request.rb', line 60 def to_json(*_args) { "combinator": METADATA_FILTER_RULE_COMBINATOR[@combinator] || @combinator, "negated": @negated, "rules": @rules, "field": @field, "operator": LOGICAL_OPERATOR[@operator] || @operator, "value": @value }.to_json end |