Sha256: a2b7a82fcce90a6672b0fb9acf9837e1370bb7b3f7688b9c33b4ba5d18ac49f8
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
# encoding: utf-8 module Sinatra module SubscriptionHelper def notify_to(user,creator,title,message,label,link=nil) #return if creator.id == user.id notification = Notification.find_or_create(:user_id => user.id, :creator_id => creator.id, :title => title, :message => message, :label => label, :link => link, :creation_date => Date.today) if link.nil? notification.link = "/notifications/#{notification.id}" notification.save end notification end def notify(creator,title,message,label,link=nil) Subscription.where(:label => label).all.each do |subscription| notification = notify_to(subscription.user,creator,title,message,label,link) end end def notify_error(creator,title,message) Subscription.where(:label => 'error').all.each do |subscription| notification = Notification.find(:user_id => subscription.user_id, :creator_id => creator.id, :title => title, :message => message, :label => 'error', :read_date => nil) if notification.nil? notification = notify_to(subscription.user,creator,title,message,'error') end end end end helpers SubscriptionHelper end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinatra-hexacta-0.0.2 | lib/sinatra/helpers/subscriptions.rb |
sinatra-hexacta-0.0.1 | lib/sinatra/helpers/subscriptions.rb |