Sha256: b0d3fd0b0eed720d0f5d78a64e177f1dd4e8c0dac7dee67daff6124e3cf3040f
Contents?: true
Size: 608 Bytes
Versions: 31
Compression:
Stored size: 608 Bytes
Contents
# frozen_string_literal: true require "forwardable" module ActiveMocker class TemplateCreator def initialize(erb_template:, file_out: nil, binding:, post_process: -> (str) { str }) @erb_template = erb_template @binding = binding @file_out = file_out || Tempfile.new("TemplateModel") @post_process = post_process end def render template = ERB.new(erb_template.read, nil, ">") file_out.write post_process.call(template.result(binding)) file_out end private attr_reader :erb_template, :binding, :file_out, :post_process end end
Version data entries
31 entries across 31 versions & 1 rubygems