Sha256: 9221f100195dfa9b7ffc74549655b542367eef81af305ed4a124762d36ce1dfe

Contents?: true

Size: 607 Bytes

Versions: 4

Compression:

Stored size: 607 Bytes

Contents

module SoarAuditorApi
  class Serializable
    def initialize (data)
      @data = data
    end

    def serialize
      begin
        require "base64"
        utf8_data = @data.to_s.encode(Encoding::UTF_8)
        urlsafe_base64_data = Base64.urlsafe_encode64(utf8_data)
        "[serialized:#{urlsafe_base64_data}]"
      rescue
        raise SerializationError, "General failure serializing the object data"
      end
    end

    def to_s
      raise NotImplementedError, "Class must implement to_s method when extending Serializable"
    end
  end

  class SerializationError < StandardError
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
soar_auditor_api-1.0.0 lib/soar_auditor_api/serializable.rb
soar_auditor_api-0.0.12 lib/soar_auditor_api/serializable.rb
soar_auditor_api-0.0.11 lib/soar_auditor_api/serializable.rb
soar_auditor_api-0.0.10 lib/soar_auditor_api/serializable.rb