Class: Biovision::Notifiers::SocializationNotifier

Inherits:
BaseNotifier
  • Object
show all
Defined in:
app/lib/biovision/notifiers/socialization_notifier.rb

Overview

Notification mapper for socialization component

Constant Summary collapse

TYPE_FOLLOWER =
'follower'
TYPE_MESSAGE =
'message'

Instance Attribute Summary

Attributes inherited from BaseNotifier

#notification, #user

Instance Method Summary collapse

Methods inherited from BaseNotifier

[], #component, handler_class, #initialize, #notify, slug, #view

Constructor Details

This class inherits a constructor from Biovision::Notifiers::BaseNotifier

Instance Method Details

#entityObject



10
11
12
13
14
15
16
17
18
# File 'app/lib/biovision/notifiers/socialization_notifier.rb', line 10

def entity
  data = notification&.data.to_h
  case data['type']
  when TYPE_MESSAGE, TYPE_FOLLOWER
    User.find_by(id: data['id'])
  else
    nil
  end
end

#new_follower(follower_id) ⇒ Object

Parameters:

  • follower_id (Integer)


26
27
28
# File 'app/lib/biovision/notifiers/socialization_notifier.rb', line 26

def new_follower(follower_id)
  check_and_notify(follower_id, TYPE_FOLLOWER)
end

#new_message(sender_id) ⇒ Object

Parameters:

  • sender_id (Integer)


21
22
23
# File 'app/lib/biovision/notifiers/socialization_notifier.rb', line 21

def new_message(sender_id)
  check_and_notify(sender_id, TYPE_MESSAGE)
end