5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/flyer/controller_additions.rb', line 5
def notifications
@notifications ||= begin
limit = Flyer.settings.max_notifications ||
Flyer::Notification.notifications.count
found_notifications = []
count = 0
Flyer::Notification.notifications.each do |n|
notification = Flyer::Notification.new(self)
n.call(notification)
notification.validate!
if notification.visible? and count < limit
notification.used!
found_notifications << notification.view
count += 1
end
end
ids = found_notifications.map(&:id)
unless ids.uniq.count == ids.count
raise Flyer::FoundNonUniqueIds.new
end
found_notifications
end
end
|