Class: RubyEventStore::Mappers::Pipeline
- Inherits:
-
Object
- Object
- RubyEventStore::Mappers::Pipeline
- Defined in:
- lib/ruby_event_store/mappers/pipeline.rb
Instance Attribute Summary collapse
-
#transformations ⇒ Object
readonly
Returns the value of attribute transformations.
Instance Method Summary collapse
- #dump(event) ⇒ Object
-
#initialize(*transformations, to_domain_event: Transformation::DomainEvent.new) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #load(record) ⇒ Object
Constructor Details
#initialize(*transformations, to_domain_event: Transformation::DomainEvent.new) ⇒ Pipeline
Returns a new instance of Pipeline.
6 7 8 |
# File 'lib/ruby_event_store/mappers/pipeline.rb', line 6 def initialize(*transformations, to_domain_event: Transformation::DomainEvent.new) @transformations = [to_domain_event, transformations].flatten.freeze end |
Instance Attribute Details
#transformations ⇒ Object (readonly)
Returns the value of attribute transformations.
18 19 20 |
# File 'lib/ruby_event_store/mappers/pipeline.rb', line 18 def transformations @transformations end |
Instance Method Details
#dump(event) ⇒ Object
10 11 12 |
# File 'lib/ruby_event_store/mappers/pipeline.rb', line 10 def dump(event) transformations.reduce(event) { |item, transform| transform.dump(item) } end |
#load(record) ⇒ Object
14 15 16 |
# File 'lib/ruby_event_store/mappers/pipeline.rb', line 14 def load(record) transformations.reverse.reduce(record) { |item, transform| transform.load(item) } end |