Sha256: cd116f4a2140399b5223b6c23aaa4b72c598e9b8a5b1a30d2488e8a728864b68

Contents?: true

Size: 617 Bytes

Versions: 5

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true

require "active_job"
require_relative "webhook"

module Flipper
  module Notifications
    module Webhooks
      class Serializer < ActiveJob::Serializers::ObjectSerializer

        def serialize?(argument)
          argument.is_a?(Webhook)
        end

        def serialize(webhook)
          super(
            "class"      => webhook.class.name,
            "attributes" => webhook.serialized_attributes
          )
        end

        def deserialize(hash)
          hash["class"].constantize.new(**hash["attributes"].deep_symbolize_keys)
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flipper-notifications-0.1.5 lib/flipper/notifications/webhooks/serializer.rb
flipper-notifications-0.1.4 lib/flipper/notifications/webhooks/serializer.rb
flipper-notifications-0.1.3 lib/flipper/notifications/webhooks/serializer.rb
flipper-notifications-0.1.2 lib/flipper/notifications/webhooks/serializer.rb
flipper-notifications-0.1.1 lib/flipper/notifications/webhooks/serializer.rb