Class: Loco::Notification

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/loco/notification.rb,
app/services/loco/notification/fetcher.rb

Defined Under Namespace

Classes: Fetcher

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#objObject

Returns the value of attribute obj.



5
6
7
# File 'app/models/loco/notification.rb', line 5

def obj
  @obj
end

Class Method Details

.table_name_prefixObject



15
16
17
# File 'app/models/loco/notification.rb', line 15

def table_name_prefix
  'loco_'
end

Instance Method Details

#compactObject



55
56
57
# File 'app/models/loco/notification.rb', line 55

def compact
  [obj_class, obj_id, event, data]
end

#prepareObject



50
51
52
53
# File 'app/models/loco/notification.rb', line 50

def prepare
  set_event
  set_data
end

#recipient(opts = {}) ⇒ Object



43
44
45
46
47
48
# File 'app/models/loco/notification.rb', line 43

def recipient opts = {}
  return recipient_token if recipient_token
  return unless regular_recipient?
  return class_recipient unless recipient_id
  obj_recipient opts[:shallow]
end

#recipient=(val) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/loco/notification.rb', line 30

def recipient= val
  return if val.nil?
  return if val == :all
  if val.is_a? String
    self.recipient_token = val
  elsif val.instance_of? Class
    self.recipient_class = val.to_s
  else
    self.recipient_class = val.class.name
    self.recipient_id = val.id
  end
end