Module: Eventsimple::Entity
- Defined in:
- lib/eventsimple/entity.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Constant Summary collapse
- DEFAULT_IGNORE_PROPS =
%w[id lock_version].freeze
Instance Method Summary collapse
Instance Method Details
#event_driven_by(event_klass, aggregate_id:, filter_attributes: []) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/eventsimple/entity.rb', line 5 def event_driven_by(event_klass, aggregate_id:, filter_attributes: []) has_many :events, class_name: event_klass.name.to_s, foreign_key: :aggregate_id, primary_key: aggregate_id, dependent: :delete_all, inverse_of: model_name.element.to_sym, autosave: false, validate: false after_initialize :readonly! class_attribute :ignored_for_projection, default: [] class_attribute :_filter_attributes self._filter_attributes = [aggregate_id] | Array.wrap(filter_attributes) # disable automatic timestamp updates self. = false Eventsimple.configuration.ui_visible_models |= [self] include InstanceMethods extend ClassMethods end |