Module: Raif::Concerns::JsonSchemaDefinition
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/raif/concerns/json_schema_definition.rb
Instance Method Summary collapse
-
#schema_for_instance(schema_name) ⇒ Object
Instance method to build schema with instance context.
Instance Method Details
#schema_for_instance(schema_name) ⇒ Object
Instance method to build schema with instance context
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/raif/concerns/json_schema_definition.rb', line 48 def schema_for_instance(schema_name) block = self.class.instance_variable_get(:@schema_blocks)&.[](schema_name) if block # Build schema with instance context builder = Raif::JsonSchemaBuilder.new builder.build_with_instance(self, &block) builder.to_schema elsif self.class.schema_defined?(schema_name) # Fall back to class-level schema self.class.schema_for(schema_name) end end |