Class: NotificationSender
- Inherits:
-
Object
- Object
- NotificationSender
- Includes:
- Singleton
- Defined in:
- lib/sinatra/extensions/notification.rb
Instance Method Summary collapse
- #send_error(creator, title, message) ⇒ Object
- #send_to(user, creator, title, message, label, link = nil) ⇒ Object
- #send_to_subscriptors(creator, title, message, label, link = nil) ⇒ Object
Instance Method Details
#send_error(creator, title, message) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sinatra/extensions/notification.rb', line 28 def send_error(creator,title,) Subscription.where(:label => 'error').all.each do |subscription| creator = subscription.user if creator.nil? notification = Notification.find(:user_id => subscription.user_id, :creator_id => creator.id, :title => title, :message => , :label => 'error', :read_date => nil) if notification.nil? notification = send_to(subscription.user,creator,title,,'error') end end end |
#send_to(user, creator, title, message, label, link = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sinatra/extensions/notification.rb', line 7 def send_to(user,creator,title,,label,link=nil) notification = Notification.find_or_create(:user_id => user.id, :creator_id => creator.id, :title => title, :message => , :label => label, :link => link, :creation_date => Date.today) if link.nil? notification.link = "/notifications/#{notification.id}" notification.save end notification end |
#send_to_subscriptors(creator, title, message, label, link = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/sinatra/extensions/notification.rb', line 22 def send_to_subscriptors(creator,title,,label,link=nil) Subscription.where(:label => label).all.each do |subscription| notification = send_to(subscription.user,creator,title,,label,link) end end |