Class: Thredded::TopicCommon::CachingHash

Inherits:
Hash
  • Object
show all
Defined in:
app/models/concerns/thredded/topic_common.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_relation(postable_relation) ⇒ Object



89
90
91
# File 'app/models/concerns/thredded/topic_common.rb', line 89

def self.from_relation(postable_relation)
  self[postable_relation.map { |related| [related.postable_id, related] }]
end

Instance Method Details

#[](postable) ⇒ Object

lookup related item by postable and set the inverse lookup



94
95
96
# File 'app/models/concerns/thredded/topic_common.rb', line 94

def [](postable)
  super(postable.id).tap { |related| related.postable = postable if related }
end