2022-11-14 09:25:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Context
|
2022-11-15 09:33:05 +00:00
|
|
|
attr_reader :old_data
|
|
|
|
attr_accessor :data, :todo_rename_this
|
2022-11-14 09:25:28 +00:00
|
|
|
|
2022-11-15 09:33:05 +00:00
|
|
|
def initialize(todo_rename_this, keys = {})
|
|
|
|
@todo_rename_this = todo_rename_this # the obj holding the parsed chunk
|
2022-11-16 09:50:54 +00:00
|
|
|
@cancel = false
|
2022-11-14 09:25:28 +00:00
|
|
|
@old_data = keys
|
|
|
|
@data = keys
|
|
|
|
end
|
|
|
|
|
|
|
|
def verify
|
|
|
|
@data.each do |key, _value|
|
|
|
|
next if @old_data.key? key
|
|
|
|
|
|
|
|
raise "Error: invalid data key '#{key}'\n valid keys: #{@old_data.keys}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-11-16 09:50:54 +00:00
|
|
|
def canceld?
|
|
|
|
@cancel
|
2022-11-14 09:25:28 +00:00
|
|
|
end
|
|
|
|
|
2022-11-16 09:50:54 +00:00
|
|
|
def cancel
|
|
|
|
@cancel = true
|
2022-11-14 09:25:28 +00:00
|
|
|
end
|
|
|
|
end
|