Sha256: c1e48f0dee678d96a868360758009c2f188b2384f6ebcc867340eb7bf9aa0609

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

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

    CLASS_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, class_prefix: CLASS_PREFIX)
    end
  end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nocode-0.0.10 lib/nocode/step_registry.rb
nocode-0.0.9 lib/nocode/step_registry.rb
nocode-0.0.8 lib/nocode/step_registry.rb
nocode-0.0.7 lib/nocode/step_registry.rb