Module: Swift::Playground::CLI::Definition

Includes:
ActiveSupport::Concern
Included in:
Commands::Generate, Commands::New, Global::ErrorHandling
Defined in:
lib/swift/playground/cli/definition.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(mod) ⇒ Object



15
16
17
18
19
# File 'lib/swift/playground/cli/definition.rb', line 15

def self.extended(mod)
  # Use the behaviour of the ActiveSupport::Concern modules `self.extended`
  # implementation:
  ActiveSupport::Concern.extended(mod)
end

Instance Method Details

#definition(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/swift/playground/cli/definition.rb', line 21

def definition(&block)
  self.included do
    # The use of `extend(self)` here makes sure that a module that extends
    # the Definition module will have access to its methods from within
    # the GLI command actions it defines. It will define these commands
    # inside the block it passes to its call of the `definition` method.
    extend(self)
    self.class_eval(&block)
  end
end