Module: Parliament::Grom::Decorator::Collection
- Defined in:
- lib/parliament/grom/decorator/collection.rb
Overview
Decorator namespace for Grom::Node instances with type: example.com/content/Collection Collection Grom::Node is a Contentful object associated with a web article (a WebArticle has an Audience node) Collection Grom::Node is not modelled in the data service, hence type ‘example..’ and not ‘id.parliament.uk/schema’
Instance Method Summary collapse
-
#articles ⇒ Array
Alias collectionHasArticle with fallback.
-
#description ⇒ String
Alias collectionDescription with fallback.
-
#extended_description ⇒ String
Alias collectionExtendedDescription with fallback.
-
#name ⇒ String
Alias collectionName with fallback.
-
#orphaned_ancestors(nodes = parents) ⇒ Array
Travel up the ancestry trees finding orphaned collections.
-
#parents ⇒ Array
Alias collectionHasParent with fallback.
-
#subcollections ⇒ Array
Alias collectionHasSubcollection with fallback.
Instance Method Details
#articles ⇒ Array
Alias collectionHasArticle with fallback.
32 33 34 |
# File 'lib/parliament/grom/decorator/collection.rb', line 32 def articles respond_to?(:collectionHasArticle) ? collectionHasArticle : [] end |
#description ⇒ String
Alias collectionDescription with fallback.
18 19 20 |
# File 'lib/parliament/grom/decorator/collection.rb', line 18 def description respond_to?(:collectionDescription) ? collectionDescription : '' end |
#extended_description ⇒ String
Alias collectionExtendedDescription with fallback.
25 26 27 |
# File 'lib/parliament/grom/decorator/collection.rb', line 25 def extended_description respond_to?(:collectionExtendedDescription) ? collectionExtendedDescription : '' end |
#name ⇒ String
Alias collectionName with fallback.
11 12 13 |
# File 'lib/parliament/grom/decorator/collection.rb', line 11 def name respond_to?(:collectionName) ? collectionName : '' end |
#orphaned_ancestors(nodes = parents) ⇒ Array
Travel up the ancestry trees finding orphaned collections
53 54 55 56 57 58 |
# File 'lib/parliament/grom/decorator/collection.rb', line 53 def orphaned_ancestors(nodes = parents) orphans = nodes.select { |node| node.parents.none? } parent_nodes = (nodes - orphans).map(&:parents).flatten orphans += orphaned_ancestors(parent_nodes) if parent_nodes.any? orphans end |
#parents ⇒ Array
Alias collectionHasParent with fallback.
46 47 48 |
# File 'lib/parliament/grom/decorator/collection.rb', line 46 def parents respond_to?(:collectionHasParent) ? collectionHasParent : [] end |
#subcollections ⇒ Array
Alias collectionHasSubcollection with fallback.
39 40 41 |
# File 'lib/parliament/grom/decorator/collection.rb', line 39 def subcollections respond_to?(:collectionHasSubcollection) ? collectionHasSubcollection : [] end |