Class: EventSourcing::Event
- Inherits:
-
Object
- Object
- EventSourcing::Event
- Defined in:
- lib/event_sourcing/event.rb,
lib/event_sourcing/event/bus.rb,
lib/event_sourcing/event/store.rb,
lib/event_sourcing/event/stream.rb,
lib/event_sourcing/event/publisher.rb,
lib/event_sourcing/event/subscriber.rb,
lib/event_sourcing/event/store/memory.rb,
lib/event_sourcing/event/bus/reference.rb,
lib/event_sourcing/event/publisher/reference.rb
Defined Under Namespace
Modules: Store Classes: Bus, Publisher, Stream, Subscriber
Class Method Summary collapse
Class Method Details
.define(*fields) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/event_sourcing/event.rb', line 6 def self.define(*fields) Class.new(self) do attr_reader(*fields) public_class_method :new define_method :initialize do |properties = {}| missing_keys = fields - properties.keys if missing_keys.any? raise ArgumentError, "missing keyword: #{missing_keys.first}" end fields.each do |field| instance_variable_set("@#{field}", properties[field]) end end def to_s self.class.to_s end end end |