module Victor::Marshaling

Public Instance Methods

encode_with(coder) click to toggle source

YAML serialization methods

# File lib/victor/marshaling.rb, line 8
def encode_with(coder)
  marshaling.each do |attr|
    coder[attr.to_s] = send(attr)
  end
end
init_with(coder) click to toggle source
# File lib/victor/marshaling.rb, line 14
def init_with(coder)
  marshaling.each do |attr|
    instance_variable_set(:"@#{attr}", coder[attr.to_s])
  end
end
marshal_dump() click to toggle source

Marshal serialization methods

# File lib/victor/marshaling.rb, line 21
def marshal_dump
  marshaling.to_h do |attr|
    [attr, send(attr)]
  end
end
marshal_load(data) click to toggle source
# File lib/victor/marshaling.rb, line 27
def marshal_load(data)
  marshaling.each do |attr|
    instance_variable_set(:"@#{attr}", data[attr])
  end
end
marshaling() click to toggle source
# File lib/victor/marshaling.rb, line 3
def marshaling
  raise NotImplementedError, "#{self.class.name} must implement `marshaling'"
end