Module: Diaspora::Federated::Fetchable::ClassMethods

Defined in:
lib/diaspora/federated/fetchable.rb

Instance Method Summary collapse

Instance Method Details

#find_or_fetch_by(diaspora_id, guid) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/diaspora/federated/fetchable.rb', line 9

def find_or_fetch_by(diaspora_id, guid)
  instance = find_by(guid: guid)
  return instance if instance.present?

  DiasporaFederation::Federation::Fetcher.fetch_public(diaspora_id, to_s, guid)
  find_by(guid: guid)
rescue DiasporaFederation::Federation::Fetcher::NotFetchable
  nil
end