Sha256: a297fd42b339d26182a36aac769cc3e5413becefd8fb0353e32e23d53f41bb41

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

module Metacrunch
  class Transformer
    require_relative "./transformer/step"
    require_relative "./transformer/helper"

    attr_accessor :source, :target, :options


    def initialize(source:nil, target:nil, options: {})
      @source  = source
      @target  = target
      @options = options
    end

    def transform(step_class = nil, &block)
      if block_given?
        Step.new(self).instance_eval(&block) # TODO: Benchmark this
      else
        raise ArgumentError, "You need to provide a STEP or a block" if step_class.nil?
        step_class.new(self).perform
      end
    end

    def helper
      @helper ||= Helper.new(self)
    end

    def register_helper(helper_module)
      raise ArgumentError, "Must be a module" unless helper_module.is_a?(Module)
      helper.class.send(:include, helper_module) # TODO: Benchmark this
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metacrunch-2.1.1 lib/metacrunch/transformer.rb