mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
This adapter basically doesn't do anything, and just serializes the attributes into plain old JSON.
21 lines
330 B
Ruby
21 lines
330 B
Ruby
class Model
|
|
def initialize(hash={})
|
|
@attributes = hash
|
|
end
|
|
|
|
def read_attribute_for_serialization(name)
|
|
if name == :id || name == 'id'
|
|
object_id
|
|
else
|
|
@attributes[name]
|
|
end
|
|
end
|
|
end
|
|
|
|
class Profile < Model
|
|
end
|
|
|
|
class ProfileSerializer < ActiveModel::Serializer
|
|
attributes :name, :description
|
|
end
|