Module: ActsAsMessageable::Relation
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/acts_as_messageable/relation.rb
Instance Attribute Summary collapse
-
#relation_context ⇒ Object
Returns the value of attribute relation_context.
Instance Method Summary collapse
- #conversations ⇒ Array<ActsAsMessageable::Message>, ActiveRecord::Relation
- #process(context = relation_context) ⇒ Object
Instance Attribute Details
#relation_context ⇒ Object
Returns the value of attribute relation_context.
10 11 12 |
# File 'lib/acts_as_messageable/relation.rb', line 10 def relation_context @relation_context end |
Instance Method Details
#conversations ⇒ Array<ActsAsMessageable::Message>, ActiveRecord::Relation
30 31 32 33 |
# File 'lib/acts_as_messageable/relation.rb', line 30 def conversations relation = T.cast(self, ActiveRecord::Relation) relation.map { || .root.subtree.order('id desc').first }.uniq end |
#process(context = relation_context) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/acts_as_messageable/relation.rb', line 18 def process(context = relation_context) relation = T.cast(self, ActiveRecord::Relation) relation.each do || yield() if block_given? context.() if .removed context.() if .restored end end |