Sha256: d1214289db7bf0c5e50f268797e814796115d8a44c12c8ff01adec4e74175e8b

Contents?: true

Size: 432 Bytes

Versions: 3

Compression:

Stored size: 432 Bytes

Contents

# -*- encoding : utf-8 -*-
module Pacto
  class ERBProcessor
    include Logger
    def process(contract, values = {})
      erb = ERB.new(contract)
      erb_result = erb.result hash_binding(values)
      logger.debug "Processed contract: #{erb_result.inspect}"
      erb_result
    end

    private

    def hash_binding(values)
      namespace = OpenStruct.new(values)
      namespace.instance_eval { binding }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pacto-0.4.0.rc3 lib/pacto/erb_processor.rb
pacto-0.4.0.rc2 lib/pacto/erb_processor.rb
pacto-0.4.0.rc1 lib/pacto/erb_processor.rb