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

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

Overview

Appends custom path to default template roots.

Instance Method Summary collapse

Constructor Details

#initialize(key = :template_roots, default: Pathname(__dir__).join("../../templates")) ⇒ TemplateRoot

Returns a new instance of TemplateRoot.



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

def initialize key = :template_roots, default: Pathname(__dir__).join("../../templates")
  @key = key
  @default = default
end

Instance Method Details

#call(attributes) ⇒ Object



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

def call attributes
  Array(default).map { |path| Pathname path }
                .including(attributes[key])
                .compact
                .then { |value| Success attributes.merge!(key => value) }
end