Sha256: 788d7223564607e4269f38ca980b42a90f4101b2c62b3b10d03d6950a5c18f1d

Contents?: true

Size: 549 Bytes

Versions: 24

Compression:

Stored size: 549 Bytes

Contents

module Actions
  module Serializers

    class ActiveRecordSerializer < ::Dynflow::Serializers::Noop
      def serialize(arg)
        if arg.is_a? ActiveRecord::Base
          { :active_record_object => true,
            :class_name => arg.class.name,
            :id => arg.id }
        else
          super arg
        end
      end

      def deserialize(arg)
        if arg.is_a?(Hash) && arg[:active_record_object]
          arg[:class_name].constantize.find(arg[:id])
        else
          super arg
        end
      end
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
foreman-tasks-0.8.6 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.8.5 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.8.4 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.8.3 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.8.2 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.8.1 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.8.0 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.20 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.19 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.18 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.17 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.16 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.15 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.14 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.13 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.12 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.11 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.10 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.9 app/lib/actions/serializers/active_record_serializer.rb
foreman-tasks-0.7.8 app/lib/actions/serializers/active_record_serializer.rb