Class: Async::Messaging::Notify

Inherits:
Object
  • Object
show all
Defined in:
lib/async-messaging/notify.rb

Class Method Summary collapse

Class Method Details

.clear_allObject



19
20
21
# File 'lib/async-messaging/notify.rb', line 19

def clear_all
  Mongoid::Message.delete_all
end

.notify_user(target_user_instance, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/async-messaging/notify.rb', line 6

def notify_user(target_user_instance, options={})
  options[:subject] ||= ""
  options[:content] ||= "" 
  options[:category] ||= :flash
  options[:flags] ||= [:notice]
  # collect source user
  s = Async::Messaging.setup
  from_user_id = s.model_root.id
  target_user_id = target_user_instance.id
  # create document entry
  Mongoid::Message.create! options.merge({from: from_user_id, to: target_user_id})
end