Module: Contentful::ResourceReferences

Included in:
Asset, Entry
Defined in:
lib/contentful/resource_references.rb

Overview

Method to retrieve references (incoming links) for a given entry or asset

Instance Method Summary collapse

Instance Method Details

#incoming_references(client = nil, query = {}) ⇒ Contentful::Array<Contentful::Entry>, false

Gets a collection of entries which links to current entry

Parameters:

Returns:



10
11
12
13
14
15
16
# File 'lib/contentful/resource_references.rb', line 10

def incoming_references(client = nil, query = {})
  return false unless client

  query = is_a?(Contentful::Entry) ? query.merge(links_to_entry: id) : query.merge(links_to_asset: id)

  client.entries(query)
end