Class: Actions::Serializers::ActiveRecordSerializer

Inherits:
Dynflow::Serializers::Noop
  • Object
show all
Defined in:
app/lib/actions/serializers/active_record_serializer.rb

Instance Method Summary collapse

Instance Method Details

#deserialize(arg) ⇒ Object



14
15
16
17
18
19
20
# File 'app/lib/actions/serializers/active_record_serializer.rb', line 14

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

#serialize(arg) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/lib/actions/serializers/active_record_serializer.rb', line 4

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