Class: RailsTransactionalOutbox::EventType

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_transactional_outbox/event_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_type) ⇒ EventType

Returns a new instance of EventType.



18
19
20
# File 'lib/rails_transactional_outbox/event_type.rb', line 18

def initialize(event_type)
  @event_type = event_type.to_sym
end

Class Method Details

.resolve_from_event_name(event_name) ⇒ Object



9
10
11
12
13
# File 'lib/rails_transactional_outbox/event_type.rb', line 9

def self.resolve_from_event_name(event_name)
  EVENT_TYPES.find(-> { raise "unknown event type: #{event_name}" }) do |event_type|
    event_name.to_s.end_with?(new(event_type).event_name_suffix)
  end
end

Instance Method Details

#destroy?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rails_transactional_outbox/event_type.rb', line 33

def destroy?
  event_type == :destroy
end

#event_name_suffixObject



26
27
28
29
30
31
# File 'lib/rails_transactional_outbox/event_type.rb', line 26

def event_name_suffix
  EVENT_TYPES
    .zip(EVENT_NAME_SUFFIXES)
    .to_h
    .fetch(event_type) { raise "unknown event type: #{event_type}" }
end

#to_symObject



22
23
24
# File 'lib/rails_transactional_outbox/event_type.rb', line 22

def to_sym
  event_type
end