Sha256: 507a2f4679ad451189f1df6452ea453fe5133c51384c5ae27f72f3cc1fc6c258

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

require 'active_support/core_ext/class/attribute'
require 'lou/transformer/step'

module Lou
  module Transformer
    def self.extended(base)
      base.class_eval do
        class_attribute(:steps)
        self.steps = []
      end
    end

    def step
      Step.new.tap do |t|
        steps << t
      end
    end

    def apply(input)
      steps.each do |t|
        input = t.apply(input)
      end
      input
    end

    def reverse(output)
      steps.reverse_each do |t|
        output = t.reverse(output)
      end
      output
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lou-0.2.0 lib/lou/transformer.rb