new serializers renamed to serializers
This commit is contained in:
parent
d817f16b4f
commit
9abf6d5ba9
10 changed files with 38 additions and 42 deletions
|
@ -16,10 +16,6 @@ class API::RestfulController < ActionController::Base
|
|||
|
||||
private
|
||||
|
||||
def resource_serializer
|
||||
"new_#{resource_name}_serializer".camelize.constantize
|
||||
end
|
||||
|
||||
def accessible_records
|
||||
if current_user
|
||||
visible_records
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class EventSerializer < ActiveModel::Serializer
|
||||
attributes :id, :sequence_id, :kind, :map_id, :created_at
|
||||
|
||||
has_one :actor, serializer: NewUserSerializer, root: 'users'
|
||||
has_one :map, serializer: NewMapSerializer
|
||||
has_one :actor, serializer: UserSerializer, root: 'users'
|
||||
has_one :map, serializer: MapSerializer
|
||||
|
||||
def actor
|
||||
object.user || object.eventable.try(:user)
|
||||
|
|
15
app/serializers/map_serializer.rb
Normal file
15
app/serializers/map_serializer.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class MapSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:name,
|
||||
:desc,
|
||||
:permission,
|
||||
:screenshot,
|
||||
:created_at,
|
||||
:updated_at
|
||||
|
||||
has_many :topics, serializer: TopicSerializer
|
||||
has_many :synapses, serializer: SynapseSerializer
|
||||
has_many :mappings, serializer: MappingSerializer
|
||||
has_many :contributors, root: :users, serializer: UserSerializer
|
||||
has_many :collaborators, root: :users, serializer: UserSerializer
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
class NewMappingSerializer < ActiveModel::Serializer
|
||||
class MappingSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:xloc,
|
||||
:yloc,
|
||||
|
@ -7,8 +7,8 @@ class NewMappingSerializer < ActiveModel::Serializer
|
|||
:mappable_id,
|
||||
:mappable_type
|
||||
|
||||
has_one :user, serializer: NewUserSerializer
|
||||
has_one :map, serializer: NewMapSerializer
|
||||
has_one :user, serializer: UserSerializer
|
||||
has_one :map, serializer: MapSerializer
|
||||
|
||||
def filter(keys)
|
||||
keys.delete(:xloc) unless object.mappable_type == 'Topic'
|
|
@ -1,4 +1,4 @@
|
|||
class NewMetacodeSerializer < ActiveModel::Serializer
|
||||
class MetacodeSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:name,
|
||||
:manual_icon,
|
|
@ -1,15 +0,0 @@
|
|||
class NewMapSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:name,
|
||||
:desc,
|
||||
:permission,
|
||||
:screenshot,
|
||||
:created_at,
|
||||
:updated_at
|
||||
|
||||
has_many :topics, serializer: NewTopicSerializer
|
||||
has_many :synapses, serializer: NewSynapseSerializer
|
||||
has_many :mappings, serializer: NewMappingSerializer
|
||||
has_many :contributors, root: :users, serializer: NewUserSerializer
|
||||
has_many :collaborators, root: :users, serializer: NewUserSerializer
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
class NewSynapseSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:desc,
|
||||
:category,
|
||||
:weight,
|
||||
:permission,
|
||||
:created_at,
|
||||
:updated_at
|
||||
|
||||
has_one :topic1, root: :topics, serializer: NewTopicSerializer
|
||||
has_one :topic2, root: :topics, serializer: NewTopicSerializer
|
||||
has_one :user, serializer: NewUserSerializer
|
||||
end
|
13
app/serializers/synapse_serializer.rb
Normal file
13
app/serializers/synapse_serializer.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class SynapseSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:desc,
|
||||
:category,
|
||||
:weight,
|
||||
:permission,
|
||||
:created_at,
|
||||
:updated_at
|
||||
|
||||
has_one :topic1, root: :topics, serializer: TopicSerializer
|
||||
has_one :topic2, root: :topics, serializer: TopicSerializer
|
||||
has_one :user, serializer: UserSerializer
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
class NewTopicSerializer < ActiveModel::Serializer
|
||||
class TopicSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:name,
|
||||
:desc,
|
||||
|
@ -7,6 +7,6 @@ class NewTopicSerializer < ActiveModel::Serializer
|
|||
:created_at,
|
||||
:updated_at
|
||||
|
||||
has_one :user, serializer: NewUserSerializer
|
||||
has_one :metacode, serializer: NewMetacodeSerializer
|
||||
has_one :user, serializer: UserSerializer
|
||||
has_one :metacode, serializer: MetacodeSerializer
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
class NewUserSerializer < ActiveModel::Serializer
|
||||
class UserSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:name,
|
||||
:avatar,
|
Loading…
Add table
Reference in a new issue