Class: EventEngine::SchemaCompatibility

Inherits:
Object
  • Object
show all
Defined in:
lib/event_engine/schema_compatibility.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(old:, new:) ⇒ SchemaCompatibility

Returns a new instance of SchemaCompatibility.



15
16
17
18
# File 'lib/event_engine/schema_compatibility.rb', line 15

def initialize(old:, new:)
  @old = old
  @new = new
end

Class Method Details

.violations(old_registry:, new_registry:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/event_engine/schema_compatibility.rb', line 3

def self.violations(old_registry:, new_registry:)
  new_registry.events.flat_map do |event|
    previous = old_registry.latest_for(event)
    next [] unless previous

    current = new_registry.latest_for(event)
    new(old: previous, new: current).breaking_changes.map do |change|
      "#{event}: #{change}"
    end
  end
end

Instance Method Details

#breaking_changesObject



20
21
22
# File 'lib/event_engine/schema_compatibility.rb', line 20

def breaking_changes
  removed_required_fields + newly_required_fields
end