Sha256: 59f2d821342b8085d05d6db65ce3e69ffb4ddb9ddf383a93f508ef195c7d2276

Contents?: true

Size: 684 Bytes

Versions: 13

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true

module ActiveResource
  class ActiveJobSerializer < ActiveJob::Serializers::ObjectSerializer
    def serialize(resource)
      super(
        "class" => resource.class.name,
        "persisted" => resource.persisted?,
        "prefix_options" => resource.prefix_options.as_json,
        "attributes" => resource.attributes.as_json
      )
    end

    def deserialize(hash)
      hash["class"].constantize.new(hash["attributes"]).tap do |resource|
        resource.persisted      = hash["persisted"]
        resource.prefix_options = hash["prefix_options"]
      end
    end

    private
      def klass
        ActiveResource::Base
      end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
activeresource-6.1.4 lib/active_resource/active_job_serializer.rb
activeresource-6.1.3 lib/active_resource/active_job_serializer.rb
activeresource-6.1.2 lib/active_resource/active_job_serializer.rb
activeresource-6.1.1 lib/active_resource/active_job_serializer.rb
activeresource-6.1.0 lib/active_resource/active_job_serializer.rb
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/activeresource-5.1.1/lib/active_resource/active_job_serializer.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/activeresource-5.1.1/lib/active_resource/active_job_serializer.rb
activeresource-6.0.0 lib/active_resource/active_job_serializer.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/activeresource-5.1.1/lib/active_resource/active_job_serializer.rb
activeresource-5.1.1 lib/active_resource/active_job_serializer.rb
ric-0.13.0 vendor/bundle/ruby/2.5.0/gems/activeresource-5.1.0/lib/active_resource/active_job_serializer.rb
ric-0.12.2 vendor/bundle/ruby/2.5.0/gems/activeresource-5.1.0/lib/active_resource/active_job_serializer.rb
activeresource-5.1.0 lib/active_resource/active_job_serializer.rb