Sha256: 1142067c669dea0669a1f81a9ca2d86b676cb5e9264c3861855676abd1d0fec8

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

require_relative 'step'

# This will execute the StepRegisty's load! method upon script evaluation.
module Nocode
  # Provides a global place to register all valid steps by their types.  By default the
  # steps directory will be autoloaded and their paths will be used as their types.  For example:
  # for the class: steps/io/write, it would register as "io/write" type.
  class StepRegistry < Util::ClassRegistry
    include Singleton

    PREFIX = 'Nocode::Steps::'
    DIR    = File.join(__dir__, 'steps')

    class << self
      extend Forwardable

      def_delegators :instance,
                     :register,
                     :constant!,
                     :add,
                     :load!
    end

    def load!
      files_loaded = Util::ClassLoader.new(DIR).load!

      # Class the parent to load up the registry with the files we found.
      load(files_loaded, PREFIX)
    end
  end

  # Call upon class evaluation to autoload all classes.
  StepRegistry.load!
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nocode-0.0.6 lib/nocode/step_registry.rb
nocode-0.0.5 lib/nocode/step_registry.rb
nocode-0.0.4 lib/nocode/step_registry.rb