Class: Eventifier::NotificationMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/eventifier/notifier/notification_mapping.rb

Class Method Summary collapse

Class Method Details

.add(key, relation) ⇒ Object



2
3
4
# File 'lib/eventifier/notifier/notification_mapping.rb', line 2

def self.add(key, relation)
  notification_mappings[key] << relation
end

.allObject



10
11
12
# File 'lib/eventifier/notifier/notification_mapping.rb', line 10

def self.all
  notification_mappings
end

.find(key) ⇒ Object



6
7
8
# File 'lib/eventifier/notifier/notification_mapping.rb', line 6

def self.find(key)
  notification_mappings[key]
end

.users_and_relations(event, key, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/eventifier/notifier/notification_mapping.rb', line 14

def self.users_and_relations(event, key, &block)
  users = Hash.new { |hash, key| hash[key] = [] }

  find(key).each do |relation|
    Eventifier::Relationship.new(event.eventable, relation).users.each do |user|
      users[user] << relation
      users[user].uniq!
    end
  end

  users.each(&block)
end