Class: ConfigTemplates::Models::Compilation

Inherits:
Object
  • Object
show all
Defined in:
lib/config_templates/models/compilation.rb

Instance Method Summary collapse

Constructor Details

#initialize(outputs) ⇒ Compilation

Returns a new instance of Compilation.



5
6
7
8
# File 'lib/config_templates/models/compilation.rb', line 5

def initialize(outputs)
  @outputs = outputs
  @context = ::ConfigTemplates::Contexts::Compilation.new
end

Instance Method Details

#reject(expression) ⇒ Object



15
16
17
18
# File 'lib/config_templates/models/compilation.rb', line 15

def reject(expression)
  @context.criteria ::ConfigTemplates::Criteria::Name.new expression, false
  self
end

#select(expression) ⇒ Object



10
11
12
13
# File 'lib/config_templates/models/compilation.rb', line 10

def select(expression)
  @context.criteria ::ConfigTemplates::Criteria::Name.new expression
  self
end

#send_to(output_name) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/config_templates/models/compilation.rb', line 20

def send_to(output_name)
  @context.components.tap do |collection|
    collection.find_all.each &:render
    collection.find_all.each &:validate!
    output = @outputs.find_by_name output_name
    collection.find_all.each { |component| output.write component }
  end
end