Class: Etcher::Transformers::Root

Inherits:
Object
  • Object
show all
Defined in:
lib/etcher/transformers/root.rb

Overview

Conditionally updates value based on path.

Instance Method Summary collapse

Constructor Details

#initialize(key, fallback: Pathname.pwd) ⇒ Root

Returns a new instance of Root.



15
16
17
18
19
# File 'lib/etcher/transformers/root.rb', line 15

def initialize key, fallback: Pathname.pwd
  @key = key
  @fallback = fallback
  freeze
end

Instance Method Details

#call(attributes) ⇒ Object



21
22
23
24
# File 'lib/etcher/transformers/root.rb', line 21

def call attributes
  value = attributes.fetch_value(key) { fallback }
  Success attributes.merge!(key => Pathname(value).expand_path)
end