TeapotSourceTeapotTarget

class Target

A build target.

Definitions

def initialize(*)

Initialize a new target.

Implementation

def initialize(*)
	super
	
	@build = nil
end

def freeze

Make the target immutable after it has been completely defined with dependencies and build rules.

Implementation

def freeze
	return self if frozen?
	
	@build.freeze
	
	super
end

def build(&block)

Define the build block for this target.

Signature

parameter block Proc | Nil

The build block.

returns Proc | Nil

The build block.

Implementation

def build(&block)
	if block_given?
		@build = block
	end
	
	return @build
end

def update_environments!

Update environments with the build block.

Implementation

def update_environments!
	return unless @build
	
	self.provisions.each do |key, provision|
		build = @build
		original = provision.value
		
		wrapper = proc do |*arguments|
			self.instance_exec(*arguments, &original) if original
			self.instance_exec(*arguments, &build) if build
		end
		
		provision.value = wrapper
	end
	
	@build = nil
end