Module: GeneratorHelpers

Defined in:
lib/generator_helpers.rb

Overview

Helper file for generating classes

Class Method Summary collapse

Class Method Details

.inject_extension(extension_path, file_path) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/generator_helpers.rb', line 6

def self.inject_extension(extension_path, file_path)
  # Inject Ruby Patient model extensions
  template = File.read(extension_path)
  renderer = ERB.new(template, nil, '-')
  rb_model = File.read(file_path)
  rb_model.gsub!(/end/, renderer.result(binding))
  File.open(file_path, 'w') { |file| file.write(rb_model) }
end