class Dynflow::Serializers::Abstract

@abstract Used to serialize and deserialize arguments for storage in a database. Used by {DelayedPlan} to store arguments which should be passed into the {Dynflow::Action}‘s plan method when the plan is executed.

Attributes

args[R]
serialized_args[R]

Public Class Methods

new(args, serialized_args = nil) click to toggle source

@param args [Array] arguments to be serialized @param serialized_args [nil, Array] arguments in their serialized form

# File lib/dynflow/serializers/abstract.rb, line 14
def initialize(args, serialized_args = nil)
  @args = args
  @serialized_args = serialized_args
end

Public Instance Methods

args!() click to toggle source

Retrieves the arguments

@raise [RuntimeError] if the deserialized arguments are not available @return [Array] the arguments

# File lib/dynflow/serializers/abstract.rb, line 23
def args!
  raise "@args not set" if @args.nil?
  return @args
end
deserialize(arg) click to toggle source

Converts a serialized argument into its deserialized form

@param arg the argument to be deserialized

# File lib/dynflow/serializers/abstract.rb, line 65
def deserialize(arg)
  raise NotImplementedError
end
perform_deserialization!() click to toggle source

Converts arguments into their deserialized form, iterates over serialized arguments, applying {#deserialize} to each of them

@raise [RuntimeError] if the serialized arguments are not available @return [Array] the deserialized arguments

# File lib/dynflow/serializers/abstract.rb, line 51
def perform_deserialization!
  @args = serialized_args!.map { |arg| deserialize arg }
end
perform_serialization!() click to toggle source

Converts arguments into their serialized form, iterates over deserialized arguments, applying {#serialize} to each of them

@raise [RuntimeError] if the deserialized arguments are not available @return [Array] the serialized arguments

# File lib/dynflow/serializers/abstract.rb, line 42
def perform_serialization!
  @serialized_args = args!.map { |arg| serialize arg }
end
serialize(arg) click to toggle source

Converts an argument into it serialized form

@param arg the argument to be serialized

# File lib/dynflow/serializers/abstract.rb, line 58
def serialize(arg)
  raise NotImplementedError
end
serialized_args!() click to toggle source

Retrieves the arguments in the serialized form

@raise [RuntimeError] if the serialized arguments are not available @return [Array] the serialized arguments

# File lib/dynflow/serializers/abstract.rb, line 32
def serialized_args!
  raise "@serialized_args not set" if @serialized_args.nil?
  return @serialized_args
end