Class: Bauk::Gen::Contents::BaseContent

Inherits:
Object
  • Object
show all
Includes:
Utils::Log
Defined in:
lib/bauk/gen/contents/base_content.rb

Direct Known Subclasses

ErbContent, FileContent, StringContent

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ BaseContent

Returns a new instance of BaseContent.



11
12
13
14
# File 'lib/bauk/gen/contents/base_content.rb', line 11

def initialize(opts)
  @attributes = opts[:attributes]
  @config = opts[:config]
end

Instance Method Details

#contentObject



16
17
18
19
20
21
22
23
24
# File 'lib/bauk/gen/contents/base_content.rb', line 16

def content
  renderer = ERB.new(File.read(@file))
  begin
    renderer.result(OpenStruct.new(@config).instance_eval { binding })
  rescue => e
    log.error("ERROR IN FILE: #{@file}")
    throw e
  end
end