Class: NotificationSerializer

Inherits:
BaseSerializer
  • Object
show all
Defined in:
app/serializers/notification_serializer.rb

Instance Method Summary collapse

Methods inherited from BaseSerializer

#abilities, #cache, #can?, #current_ability, #owner?

Instance Method Details

#actorObject


20
21
22
# File 'app/serializers/notification_serializer.rb', line 20

def actor
  object.actor
end

#mentionObject


30
31
32
33
# File 'app/serializers/notification_serializer.rb', line 30

def mention
  return nil if object.notify_type != 'mention'
  object.target
end

#mention_typeObject


24
25
26
27
# File 'app/serializers/notification_serializer.rb', line 24

def mention_type
  return nil if object.notify_type != 'mention'
  object.target_type
end

#nodeObject


49
50
51
52
53
# File 'app/serializers/notification_serializer.rb', line 49

def node
  return nil if object.notify_type != 'node_changed'
  return nil if object.try(:second_target).blank?
  object.second_target
end

#readObject


15
16
17
# File 'app/serializers/notification_serializer.rb', line 15

def read
  object.read?
end

#replyObject


43
44
45
46
# File 'app/serializers/notification_serializer.rb', line 43

def reply
  return nil if object.notify_type != 'topic_reply'
  object.try(:target)
end

#serializable_object(options = {}) ⇒ Object


5
6
7
8
9
# File 'app/serializers/notification_serializer.rb', line 5

def serializable_object(options = {})
  cache([object, 'v1.4']) do
    super(options)
  end
end

#topicObject


36
37
38
39
40
# File 'app/serializers/notification_serializer.rb', line 36

def topic
  if object.notify_type == 'topic' || object.notify_type == 'node_changed'
    object.try(:target)
  end
end

#typeObject


11
12
13
# File 'app/serializers/notification_serializer.rb', line 11

def type
  object.notify_type.classify
end