module Sequent::Core::Helpers::AutosetAttributes
In some cases you just want to store the events as instance variables on the AggregateRoot
. In that case you can use the following code:
class LineItemsSet < Sequent::Event
attrs line_items: array(LineItem)
end
class Invoice < Sequent::AggregateRoot
self.autoset_attributes_for_events LineItemsSet
end
This will automatically create the following block
on LineItemSet do |event|
@line_items = event.line_items
end
The autoset_attributes_for_events
will set all the defined attrs
as instance variable, except for the ones defined in autoset_ignore_attributes
.
Public Class Methods
included(host_class)
click to toggle source
# File lib/sequent/core/helpers/autoset_attributes.rb, line 50 def self.included(host_class) host_class.extend(ClassMethods) end