Module: Sequent::Core::Helpers::AutosetAttributes

Included in:
AggregateRoot
Defined in:
lib/sequent/core/helpers/autoset_attributes.rb

Overview

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.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(host_class) ⇒ Object



50
51
52
# File 'lib/sequent/core/helpers/autoset_attributes.rb', line 50

def self.included(host_class)
  host_class.extend(ClassMethods)
end