Class: Yes::Core::Aggregate::Dsl::CommandGroupData

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

Overview

Data object that holds information about a command_group definition in an aggregate.

Examples:

CommandGroupData.new(:create_apprenticeship, MyAggregate, context: 'Companies', aggregate: 'Apprenticeship')

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, aggregate_class, options = {}) ⇒ CommandGroupData

Returns a new instance of CommandGroupData.

Parameters:

  • name (Symbol)

    the name of the command group

  • aggregate_class (Class)

    the aggregate class the group belongs to

  • options (Hash) (defaults to: {})

    additional options

Options Hash (options):

  • :context (String)

    the context name

  • :aggregate (String)

    the aggregate name

Since:

  • 0.1.0



21
22
23
24
25
26
27
28
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 21

def initialize(name, aggregate_class, options = {})
  @name = name
  @aggregate_class = aggregate_class
  @context_name = options[:context]
  @aggregate_name = options[:aggregate]
  @sub_command_names = []
  @guard_names = []
end

Instance Attribute Details

#aggregate_classObject (readonly)

Since:

  • 0.1.0



13
14
15
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 13

def aggregate_class
  @aggregate_class
end

#aggregate_nameObject (readonly)

Since:

  • 0.1.0



13
14
15
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 13

def aggregate_name
  @aggregate_name
end

#context_nameObject (readonly)

Since:

  • 0.1.0



13
14
15
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 13

def context_name
  @context_name
end

#guard_namesObject

Since:

  • 0.1.0



14
15
16
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 14

def guard_names
  @guard_names
end

#nameObject (readonly)

Since:

  • 0.1.0



13
14
15
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 13

def name
  @name
end

#sub_command_namesObject

Since:

  • 0.1.0



14
15
16
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 14

def sub_command_names
  @sub_command_names
end

Instance Method Details

#add_guard(name) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol)

    guard name to record on this group

Since:

  • 0.1.0



38
39
40
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 38

def add_guard(name)
  @guard_names << name
end

#add_sub_command(name) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol)

    sub-command name to append (preserves order)

Since:

  • 0.1.0



32
33
34
# File 'lib/yes/core/aggregate/dsl/command_group_data.rb', line 32

def add_sub_command(name)
  @sub_command_names << name
end