Class: Archfiend::Generators::Extensions

Inherits:
Object
  • Object
show all
Defined in:
lib/archfiend/generators/extensions.rb

Constant Summary collapse

PHASES =
%i[init exec].freeze
CALLBACK_TYPES =
%i[before after].freeze

Instance Method Summary collapse

Constructor Details

#initialize(generator_options, action_context, generator_name) ⇒ Extensions

Returns a new instance of Extensions.

Parameters:

  • generator_options (Archfiend::Generators::Options)

    Options, source of potential extensions

  • action_context (Thor::Group)

    Contex of the extended action/group of actions

  • generator_name (String)

    Underscore form name of the generator, ex. daemon



10
11
12
13
14
15
16
17
# File 'lib/archfiend/generators/extensions.rb', line 10

def initialize(generator_options, action_context, generator_name)
  @generator_options = generator_options
  @action_context = action_context
  @generator_name = generator_name

  @extensions = activate_extensions
  expose_extensions
end

Instance Method Details

#run_with_exec_callbacksObject



27
28
29
30
31
32
33
# File 'lib/archfiend/generators/extensions.rb', line 27

def run_with_exec_callbacks
  run_callback(:exec, :before)

  yield unless skip_default_action?(:exec)

  run_callback(:exec, :after)
end

#run_with_init_callbacksObject



19
20
21
22
23
24
25
# File 'lib/archfiend/generators/extensions.rb', line 19

def run_with_init_callbacks
  run_callback(:init, :before)

  yield unless skip_default_action?(:init)

  run_callback(:init, :after)
end