Sha256: 0ac569f62b008e6a7a9b70dc2df5f42e420b44896c73a118d3e68aaa46399aa0

Contents?: true

Size: 520 Bytes

Versions: 4

Compression:

Stored size: 520 Bytes

Contents

# Copyright (c) 2023 Jerome Arbez-Gindre
# frozen_string_literal: true

module Defmastership
  module Modifier
    # build modifiers from a piece of configuration
    module Factory
      # Build a concrete class from config 'type' field
      #
      # @param config [YAML] piece of configuration for this Modifier
      def self.from_config(config)
        class_name = config.fetch(:type).split('_').map(&:capitalize).join
        Modifier.const_get(class_name).new(config.fetch(:config))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
defmastership-1.3.0 lib/defmastership/modifier/factory.rb
defmastership-1.2.0 lib/defmastership/modifier/factory.rb
defmastership-1.1.1 lib/defmastership/modifier/factory.rb
defmastership-1.1.0 lib/defmastership/modifier/factory.rb