Class: Yes::Core::Aggregate::Dsl::ClassNameConvention

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

Overview

Handles the naming conventions for aggregate-related classes

Examples:

convention = ClassNameConvention.new(context: 'MyContext', aggregate: 'User')
convention.command_class_name('change_name') # => "MyContext::User::Commands::ChangeName::Command"

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(context:, aggregate:) ⇒ ClassNameConvention

Returns a new instance of ClassNameConvention.

Parameters:

  • context (String)

    The context name

  • aggregate (String)

    The aggregate name

Since:

  • 0.1.0



16
17
18
19
# File 'lib/yes/core/aggregate/dsl/class_name_convention.rb', line 16

def initialize(context:, aggregate:)
  @context = context
  @aggregate = aggregate
end

Instance Method Details

#class_name_for(type, name) ⇒ String

Returns the conventional class name for a given type and name

Parameters:

  • type (Symbol)

    The type of class (:command, :event, or :guard_evaluator, …)

  • name (Symbol, String)

    The name of the class

Returns:

  • (String)

    The conventional class name

Since:

  • 0.1.0



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

def class_name_for(type, name)
  send(:"#{type}_class_name", name)
end