Module: DslOrganizer::ExportCommand

Defined in:
lib/dsl_organizer/export_command.rb

Overview

Note:

Just include this to the target class and think up a command name.

It allows to define what a class is a executor (hook). rubocop:disable Metrics/MethodLength

Examples:

include DslOrganizer::ExportCommand[:after]

Class Method Summary collapse

Class Method Details

.[](command_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dsl_organizer/export_command.rb', line 8

def self.[](command_name)
  Module.new do
    @command_name = command_name

    def self.included(base)
      if ExportContainer[@command_name].nil?
        ExportContainer[@command_name] = base
      else
        raise(
          Errors::ExecutorDidMountEarly,
          "The component for command name: `#{@command_name}`" \
          ' was mounted early. Avoid duplication naming within commands.'
        )
      end
    end
  end
end