Class: Yes::Core::Aggregate::Dsl::MethodDefiners::Attribute::Accessor

Inherits:
Base
  • Object
show all
Defined in:
lib/yes/core/aggregate/dsl/method_definers/attribute/accessor.rb

Overview

Defines the accessor method for an attribute

Since:

  • 0.1.0

Instance Method Summary collapse

Methods inherited from Base

#initialize

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 a reader method for the attribute that reads from the read model

Since:

  • 0.1.0



13
14
15
16
17
18
19
20
21
# File 'lib/yes/core/aggregate/dsl/method_definers/attribute/accessor.rb', line 13

def call
  name = @name

  aggregate_class.define_method(name) do
    return nil unless self.class.read_model_enabled?

    read_model.public_send(name)
  end
end