Sha256: 39c342969eb9a85336565cbe4790d519956750d6ee97299bd78233c3434da922

Contents?: true

Size: 453 Bytes

Versions: 3

Compression:

Stored size: 453 Bytes

Contents

module ActsAsMessageable
  module Relation
    attr_accessor :relation_context

    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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts-as-messageable-0.4.10 lib/acts-as-messageable/relation.rb
acts-as-messageable-0.4.9 lib/acts-as-messageable/relation.rb
acts-as-messageable-0.4.8 lib/acts-as-messageable/relation.rb