Class: Etcher::Transformers::Basename

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

Overview

Conditionally updates value based on path.

Instance Method Summary collapse

Constructor Details

#initialize(key, fallback: Pathname.pwd.basename.to_s) ⇒ Basename

Returns a new instance of Basename.



14
15
16
17
# File 'lib/etcher/transformers/basename.rb', line 14

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

Instance Method Details

#call(attributes) ⇒ Object



19
20
21
22
# File 'lib/etcher/transformers/basename.rb', line 19

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