Class: Yes::Core::Aggregate::Dsl::AttributeDefiner

Inherits:
Object
  • Object
show all
Defined in:
lib/yes/core/aggregate/dsl/attribute_definer.rb

Overview

Factory class that creates the appropriate attribute definer based on the attribute type

Examples:

attribute_data = AttributeData.new(name: :name, type: :string, aggregate_class: User, validate: true)
AttributeDefiner.new(attribute_data).call do
  guard :no_change do
    payload.name == name
  end
end

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(attribute_data) ⇒ AttributeDefiner

Initializes a new AttributeDefiner instance

Parameters:

  • attribute_data (AttributeData)

    the data object containing attribute configuration

Since:

  • 0.1.0



26
27
28
# File 'lib/yes/core/aggregate/dsl/attribute_definer.rb', line 26

def initialize(attribute_data)
  @attribute_data = attribute_data
end

Instance Method Details

#call { ... } ⇒ void

This method returns an undefined value.

Creates the appropriate definer and calls it to generate the necessary classes and methods

Yields:

  • Block for defining guards and other attribute configurations

Yield Returns:

  • (void)

Since:

  • 0.1.0



35
36
37
# File 'lib/yes/core/aggregate/dsl/attribute_definer.rb', line 35

def call(&)
  definer_for_type.new(attribute_data).call(&)
end