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



91
92
93
# File 'app/models/concerns/thredded/topic_common.rb', line 91

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



96
97
98
# File 'app/models/concerns/thredded/topic_common.rb', line 96

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