Class: EasyCreds::Templates::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_creds/templates/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ Renderer

Returns a new instance of Renderer.



6
7
8
# File 'lib/easy_creds/templates/renderer.rb', line 6

def initialize(template)
  @template = template
end

Instance Method Details

#customise(prompt) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/easy_creds/templates/renderer.rb', line 10

def customise(prompt)
  return @template if @template.empty?

  result = {}
  @template.each do |section, value|
    next unless prompt.yes?("Include section '#{section}'?", default: true)

    result[section] = value.is_a?(Hash) ? customise_section(section, value, prompt) : value
  end
  result
end