class Configurious::Transformer

Public Class Methods

new() click to toggle source
# File lib/configurious/transformer.rb, line 7
def initialize
  @steps = []
end

Public Instance Methods

add(path, value) click to toggle source
# File lib/configurious/transformer.rb, line 11
def add(path, value)
  op = Configurious::Operations::Add.new
  op.path = path
  op.content = value
  @steps << op
end
apply(content) click to toggle source
# File lib/configurious/transformer.rb, line 53
def apply(content)
  @steps.each do |t|
    t.apply(content)
  end
  content
end
change(path, to:) click to toggle source
# File lib/configurious/transformer.rb, line 26
def change(path, to:)
  r = Configurious::Operations::Replace.new
  r.path = path
  r.content = to
  @steps << r
end
change_key(path, to:) click to toggle source
# File lib/configurious/transformer.rb, line 46
def change_key(path, to:)
  r = Configurious::Operations::ChangeKey.new
  r.path = path
  r.content = to
  @steps << r
end
remove(path) click to toggle source
# File lib/configurious/transformer.rb, line 40
def remove(path)
  r = Configurious::Operations::Remove.new
  r.path = path
  @steps << r
end
replace(path, with:, part: nil) click to toggle source
# File lib/configurious/transformer.rb, line 18
def replace(path, with:, part: nil)
  r = Configurious::Operations::Replace.new
  r.path = path
  r.part = part
  r.content = with
  @steps << r
end
update(path, &block) click to toggle source
# File lib/configurious/transformer.rb, line 33
def update(path, &block)
  r = Configurious::Operations::Update.new
  r.path = path
  r.applies(&block)
  @steps << r
end