Class: Yes::Core::Aggregate::Dsl::MethodDefiners::Attribute::AggregateAccessor
- Inherits:
-
Base
- Object
- Base
- Yes::Core::Aggregate::Dsl::MethodDefiners::Attribute::AggregateAccessor
- Defined in:
- lib/yes/core/aggregate/dsl/method_definers/attribute/aggregate_accessor.rb
Overview
Defines the accessor methods for an aggregate attribute
Instance Method Summary collapse
-
#call ⇒ void
Defines reader methods for the aggregate attribute that reads from the read model.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Yes::Core::Aggregate::Dsl::MethodDefiners::Attribute::Base
Instance Method Details
#call ⇒ void
This method returns an undefined value.
Defines reader methods for the aggregate attribute that reads from the read model
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yes/core/aggregate/dsl/method_definers/attribute/aggregate_accessor.rb', line 13 def call name = @name id_name = :"#{name}_id" # Define the id accessor aggregate_class.define_method(id_name) do read_model.public_send(id_name) end # Define the aggregate accessor aggregate_class.define_method(name) do id = read_model.public_send(id_name) return nil unless id "#{self.class.context}::#{name.to_s.camelize}::Aggregate".constantize.new(id) end end |