Sha256: 959274c5654f31ab8e0b90e549bb54cbef8d12537d06c7cc1ca0033d1ab64c8a

Contents?: true

Size: 1.75 KB

Versions: 6

Compression:

Stored size: 1.75 KB

Contents

module Parliament
  module Grom
    module Decorator
      # Decorator namespace for Grom::Node instances with type: http://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 'http://example..' and not 'https://id.parliament.uk/schema'
      module Collection
        # Alias collectionName with fallback.
        #
        # @return [String, String] the name of the Grom::Node or an empty string.
        def name
          respond_to?(:collectionName) ? collectionName : ''
        end

        # Alias collectionDescription with fallback.
        #
        # @return [String, String] the description of the Grom::Node or an empty string.
        def description
          respond_to?(:collectionDescription) ? collectionDescription : ''
        end

        # Alias collectionHasArticle with fallback.
        #
        # @return [Array, Array] an array of Articles related to the Grom::Node or an empty Array.
        def articles
          respond_to?(:collectionHasArticle) ? collectionHasArticle : []
        end

        # Alias collectionHasSubcollection with fallback.
        #
        # @return [Array, Array] an array of Subcollections related to the Grom::Node or an empty Array.
        def subcollections
          respond_to?(:collectionHasSubcollection) ? collectionHasSubcollection : []
        end

        # Alias collectionHasParent with fallback.
        #
        # @return [Array, Array] an array of Subcollections related to the Grom::Node or an empty Array.
        def parents
          respond_to?(:collectionHasParent) ? collectionHasParent : []
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parliament-grom-decorators-0.22.2 lib/parliament/grom/decorator/collection.rb
parliament-grom-decorators-0.22.1 lib/parliament/grom/decorator/collection.rb
parliament-grom-decorators-0.22.0 lib/parliament/grom/decorator/collection.rb
parliament-grom-decorators-0.21.0 lib/parliament/grom/decorator/collection.rb
parliament-grom-decorators-0.19.0 lib/parliament/grom/decorator/collection.rb
parliament-grom-decorators-0.18.0 lib/parliament/grom/decorator/collection.rb