Class: Rubysmith::Configuration::Transformers::TemplateRoot

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysmith/configuration/transformers/template_root.rb

Overview

Appends custom content to default template roots.

Instance Method Summary collapse

Constructor Details

#initialize(default = Pathname(__dir__).join("../../templates")) ⇒ TemplateRoot

Returns a new instance of TemplateRoot.



15
16
17
# File 'lib/rubysmith/configuration/transformers/template_root.rb', line 15

def initialize default = Pathname(__dir__).join("../../templates")
  @default = default
end

Instance Method Details

#call(content) ⇒ Object



19
20
21
22
23
24
# File 'lib/rubysmith/configuration/transformers/template_root.rb', line 19

def call content
  Array(default).map { |path| Pathname path }
                .including(content[:template_roots])
                .compact
                .then { |paths| Success content.merge!(template_roots: paths) }
end