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 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.



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

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



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

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

Instance Method Details

#apply_config(attributes) ⇒ Object



20
21
22
# File 'lib/pipely/build/template.rb', line 20

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

#respond_to_missing(method_name, include_private = false) ⇒ Object



28
29
30
# File 'lib/pipely/build/template.rb', line 28

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

#to_jsonObject



24
25
26
# File 'lib/pipely/build/template.rb', line 24

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