Module: Plutonium::Migrations

Defined in:
lib/plutonium/migrations.rb

Overview

Registry of per-feature migration paths.

Features register their migration directory against a configuration key. A path is only surfaced by Migrations.enabled_paths when its feature's config (+Plutonium.configuration.+) responds to .enabled and it is true.

Class Method Summary collapse

Class Method Details

.enabled_pathsArray<String>

Migration paths for features that are currently enabled.

Returns:

  • (Array<String>)


32
33
34
35
36
37
# File 'lib/plutonium/migrations.rb', line 32

def enabled_paths
  @registry.filter_map do |feature, path|
    cfg = Plutonium.configuration.public_send(feature) if Plutonium.configuration.respond_to?(feature)
    path if cfg&.respond_to?(:enabled) && cfg.enabled
  end
end

.register(feature, path) ⇒ String

Register a migration path for a feature.

Parameters:

  • feature (Symbol, String)

    the configuration key (e.g. :wizards)

  • path (String)

    the absolute migration directory path

Returns:

  • (String)

    the registered path



18
19
20
# File 'lib/plutonium/migrations.rb', line 18

def register(feature, path)
  @registry[feature.to_sym] = path
end

.reset!Hash

Clear the registry. Intended for tests.

Returns:

  • (Hash)


25
26
27
# File 'lib/plutonium/migrations.rb', line 25

def reset!
  @registry = {}
end