Module: Hanami::CLI::Commands::App::DB::Command::SkipTestDB Private

Defined in:
lib/hanami/cli/commands/app/db/command.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Overloads #call to allow skipping test database operations

Adds --skip-test-db option flag

Since:

  • 3.0.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



27
28
29
30
31
32
33
# File 'lib/hanami/cli/commands/app/db/command.rb', line 27

def self.prepended(klass)
  # This module is included each time the class is inherited
  # Without this check, the --skip-test-db option is duplicated each time
  unless klass.options.map(&:name).include?(:skip_test_db)
    klass.option :skip_test_db, type: :flag, default: false, desc: "Skip test database operations"
  end
end

Instance Method Details

#call(*args, **opts) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 3.0.0



37
38
39
40
41
42
43
# File 'lib/hanami/cli/commands/app/db/command.rb', line 37

def call(*args, **opts)
  if opts[:skip_test_db]
    ENV["HANAMI_CLI_DB_COMMAND_RE_RUN_IN_TEST"] = "false"
  end

  super
end