Class: Sequent::Core::Event
- Inherits:
-
Object
- Object
- Sequent::Core::Event
- Includes:
- Helpers::AttributeSupport, Helpers::Copyable, Helpers::EqualSupport, Helpers::StringSupport
- Defined in:
- lib/sequent/core/event.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Event
constructor
A new instance of Event.
- #payload ⇒ Object
Methods included from Helpers::StringSupport
Methods included from Helpers::EqualSupport
Methods included from Helpers::AttributeSupport
#as_json, #attributes, #ensure_known_attributes, included, #update, #validation_errors
Methods included from Helpers::Copyable
Constructor Details
#initialize(args = {}) ⇒ Event
Returns a new instance of Event.
18 19 20 21 22 23 24 |
# File 'lib/sequent/core/event.rb', line 18 def initialize(args = {}) update_all_attributes args fail 'Missing aggregate_id' unless @aggregate_id fail 'Missing sequence_number' unless @sequence_number @created_at ||= Time.now end |
Instance Method Details
#payload ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sequent/core/event.rb', line 26 def payload result = {} instance_variables .reject { |k| payload_variables.include?(k) } .select { |k| self.class.types.keys.include?(to_attribute_name(k)) } .each do |k| result[k.to_s[1..-1].to_sym] = instance_variable_get(k) end result end |