Class: ActiveModel::Pusher::RecordSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/pusher/record_serializer.rb

Defined Under Namespace

Classes: RecordCannotBeSerializedError

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ RecordSerializer

Returns a new instance of RecordSerializer.



16
17
18
# File 'lib/active_model/pusher/record_serializer.rb', line 16

def initialize(record)
  @record = record
end

Instance Method Details

#serialize!Object



20
21
22
23
24
# File 'lib/active_model/pusher/record_serializer.rb', line 20

def serialize!
  raise RecordCannotBeSerializedError.new(@record) unless can_be_serialized?

  serializer.as_json
end