Class: Dionysus::Consumer::DionysusEvent
- Inherits:
-
Object
- Object
- Dionysus::Consumer::DionysusEvent
- Defined in:
- lib/dionysus/consumer/dionysus_event.rb
Instance Attribute Summary collapse
-
#event_name ⇒ Object
readonly
Returns the value of attribute event_name.
-
#local_changes ⇒ Object
readonly
Returns the value of attribute local_changes.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
-
#transformed_data ⇒ Object
readonly
Returns the value of attribute transformed_data.
Instance Method Summary collapse
- #aggregate_root? ⇒ Boolean
- #created? ⇒ Boolean
- #destroyed? ⇒ Boolean
- #generic_event? ⇒ Boolean
-
#initialize(event_name, model_name, transformed_data, aggregate_root: true) ⇒ DionysusEvent
constructor
A new instance of DionysusEvent.
- #to_h ⇒ Object
- #updated? ⇒ Boolean
Constructor Details
#initialize(event_name, model_name, transformed_data, aggregate_root: true) ⇒ DionysusEvent
Returns a new instance of DionysusEvent.
6 7 8 9 10 11 12 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 6 def initialize(event_name, model_name, transformed_data, aggregate_root: true) @event_name = event_name.to_s @model_name = model_name.to_s @transformed_data = transformed_data @local_changes = {} @aggregate_root = aggregate_root end |
Instance Attribute Details
#event_name ⇒ Object (readonly)
Returns the value of attribute event_name.
4 5 6 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 4 def event_name @event_name end |
#local_changes ⇒ Object (readonly)
Returns the value of attribute local_changes.
4 5 6 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 4 def local_changes @local_changes end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
4 5 6 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 4 def model_name @model_name end |
#transformed_data ⇒ Object (readonly)
Returns the value of attribute transformed_data.
4 5 6 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 4 def transformed_data @transformed_data end |
Instance Method Details
#aggregate_root? ⇒ Boolean
30 31 32 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 30 def aggregate_root? @aggregate_root == true end |
#created? ⇒ Boolean
14 15 16 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 14 def created? event_name.end_with?("created") end |
#destroyed? ⇒ Boolean
22 23 24 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 22 def destroyed? event_name.end_with?("destroyed") end |
#generic_event? ⇒ Boolean
26 27 28 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 26 def generic_event? created? || updated? || destroyed? end |
#to_h ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 34 def to_h { event_name: event_name, model_name: model_name, transformed_data: transformed_data, local_changes: local_changes } end |
#updated? ⇒ Boolean
18 19 20 |
# File 'lib/dionysus/consumer/dionysus_event.rb', line 18 def updated? event_name.end_with?("updated") end |