Class: Pipely::Build::Template

Inherits:
Object
  • Object
show all
Includes:
TemplateHelpers
Defined in:
lib/pipely/build/template.rb

Overview

An ERB template that can be interpolated with config hashes to render a deployable pipeline definition.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TemplateHelpers

#s3_asset_path, #s3n_asset_path, #s3n_step_path, #streaming_hadoop_step

Constructor Details

#initialize(source) ⇒ Template

Returns a new instance of Template.



17
18
19
20
# File 'lib/pipely/build/template.rb', line 17

def initialize(source)
  @source = source
  @config = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/pipely/build/template.rb', line 34

def method_missing(method_name, *args, &block)
  if @config.keys.include?(method_name)
    @config[method_name]
  else
    super
  end
end

Instance Attribute Details

#pipeline_idObject

Returns the value of attribute pipeline_id.



15
16
17
# File 'lib/pipely/build/template.rb', line 15

def pipeline_id
  @pipeline_id
end

Instance Method Details

#apply_config(attributes) ⇒ Object



22
23
24
# File 'lib/pipely/build/template.rb', line 22

def apply_config(attributes)
  @config.merge!(attributes.symbolize_keys)
end

#respond_to_missing(method_name, include_private = false) ⇒ Object



30
31
32
# File 'lib/pipely/build/template.rb', line 30

def respond_to_missing(method_name, include_private=false)
  @config.keys.include?(method_name.to_s) || super
end

#to_jsonObject



26
27
28
# File 'lib/pipely/build/template.rb', line 26

def to_json
  ERB.new(@source).result(binding)
end