class NoSE::Serialize::WorkloadBuilder
Construct a new workload from a parsed hash
Public Instance Methods
call(_, input:, fragment:, represented:, **)
click to toggle source
# File lib/nose/serialize.rb, line 482 def call(_, input:, fragment:, represented:, **) workload = input.represented workload.instance_variable_set :@model, represented.model # Add all statements to the workload statement_weights = Hash.new { |h, k| h[k] = {} } fragment['weights'].each do |mix, weights| mix = mix.to_sym weights.each do |statement, weight| statement_weights[statement][mix] = weight end end fragment['statements'].each do |statement| workload.add_statement statement, statement_weights[statement], group: fragment['group'] end workload.mix = fragment['mix'].to_sym unless fragment['mix'].nil? workload end