Module: EventEngine::EventDefinition::Schemas::ClassMethods
- Defined in:
- lib/event_engine/event_definition/schemas.rb
Instance Method Summary collapse
-
#schema ⇒ Schema
Builds and returns a Schema from this definition’s DSL declarations.
-
#schema_errors ⇒ Array<String>
Returns validation errors for this definition, if any.
-
#valid_schema? ⇒ Boolean
Whether this definition has a valid schema (no errors).
Instance Method Details
#schema ⇒ Schema
Builds and returns a Schema from this definition’s DSL declarations.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/event_engine/event_definition/schemas.rb', line 79 def schema errors = schema_errors raise ArgumentError, errors.join(", ") if errors.any? required = inputs.select { |_, v| v== :required }.keys optional = inputs.select { |_, v| v== :optional }.keys Schema.new( event_name: @event_name, event_type: @event_type, process_type: @process_type, subject: @subject, domain: @domain, required_inputs: required, optional_inputs: optional, payload_fields: payload_fields ) end |
#schema_errors ⇒ Array<String>
Returns validation errors for this definition, if any.
101 102 103 104 105 106 107 |
# File 'lib/event_engine/event_definition/schemas.rb', line 101 def schema_errors errors = [] validate_identity(errors) validate_process_type(errors) validate_payload_fields(errors) errors end |
#valid_schema? ⇒ Boolean
Whether this definition has a valid schema (no errors).
112 113 114 |
# File 'lib/event_engine/event_definition/schemas.rb', line 112 def valid_schema? schema_errors.empty? end |