Class: Grumlin::StepsSerializers::Bytecode

Inherits:
Serializer
  • Object
show all
Defined in:
lib/grumlin/steps_serializers/bytecode.rb

Direct Known Subclasses

HumanReadableBytecode

Constant Summary collapse

NONE_STEP =

constructor params: no_return: true|false, default false TODO: add pretty

Grumlin::StepData.new("none")

Instance Method Summary collapse

Instance Method Details

#serializeObject



9
10
11
12
13
14
15
16
# File 'lib/grumlin/steps_serializers/bytecode.rb', line 9

def serialize
  steps = Grumlin::ShortcutsApplyer.call(@steps)
  no_return = @params.fetch(:no_return, false)
  {}.tap do |result|
    result[:step] = serialize_steps(steps.steps + (no_return ? [NONE_STEP] : [])) if steps.steps.any?
    result[:source] = serialize_steps(steps.configuration_steps) if steps.configuration_steps.any?
  end
end