Sha256: c1be6b2f7ba3009b1ee292ce65630f2b89aac03fbc1b6dc8d35b6e05c1af970e

Contents?: true

Size: 421 Bytes

Versions: 4

Compression:

Stored size: 421 Bytes

Contents

# frozen_string_literal: true

# @api private
class Phlex::Context
	def initialize
		@target = +""
		@capturing = false
	end

	attr_accessor :target, :capturing

	def capturing_into(new_target)
		original_target = @target
		original_capturing = @capturing

		begin
			@target = new_target
			@capturing = true
			yield
		ensure
			@target = original_target
			@capturing = original_capturing
		end

		new_target
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phlex-1.9.3 lib/phlex/context.rb
phlex-1.9.2 lib/phlex/context.rb
phlex-1.9.1 lib/phlex/context.rb
phlex-1.9.0 lib/phlex/context.rb