Module: ActsAsMessageable::Relation

Defined in:
lib/acts-as-messageable/relation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#relation_contextObject

Returns the value of attribute relation_context



3
4
5
# File 'lib/acts-as-messageable/relation.rb', line 3

def relation_context
  @relation_context
end

Instance Method Details

#conversationsObject



13
14
15
# File 'lib/acts-as-messageable/relation.rb', line 13

def conversations
  map { |r| r.root.subtree.order("id desc").first }.uniq
end

#process(context = self.relation_context, &block) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/acts-as-messageable/relation.rb', line 5

def process(context = self.relation_context, &block)
  self.each do |message|
    block.call(message) if block_given?
    context.delete_message(message)   if message.removed
    context.restore_message(message)  if message.restored
  end
end