Class: Builtins::Helpers::DependencyHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/builtins/helpers/dependency_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependency_set) ⇒ DependencyHandler

Returns a new instance of DependencyHandler.


12
13
14
# File 'lib/builtins/helpers/dependency_handler.rb', line 12

def initialize(dependency_set)
	@dependency_set = dependency_set
end

Instance Method Details

#dependenciesObject


16
17
18
19
20
21
22
# File 'lib/builtins/helpers/dependency_handler.rb', line 16

def dependencies
	return [] unless @dependency_set

	@dependency_set.map do |type, names|
		dependencies_for(type, names)
	end.flatten
end

#dependencies_for(type, names) ⇒ Object


24
25
26
27
28
29
30
# File 'lib/builtins/helpers/dependency_handler.rb', line 24

def dependencies_for(type, names)
	dependency_class = Dependencies.const_get(type.capitalize.to_sym, false)

	names.map { |name| dependency_class.new(name) }
rescue NameError
	Output.error("No way to handle dependencies of type '#{type}'; ignoring.")
end