Sha256: 37b9fa3b3c024379afe870f4b175e4b351506252affaf509c15e0d53cf77ecf7

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

module GeoWorks
  module Discovery
    class DocumentBuilder
      class_attribute :services, :root_path_class

      # Array of document builder services.
      # - BasicMetadataBuilder: builds fields such as id, subject, and publisher.
      # - SpatialBuilder: builds spatial fields such as bounding box and solr geometry.
      # - DateBuilder: builds date fields such as layer year and modified date.
      # - ReferencesBuilder: builds service reference fields such as thumbnail and download url.
      # - LayerInfoBuilder: builds fields about the geospatial file such as geometry and format.
      # - SlugBuilder: builds the Geoblacklight slug field.
      self.services = [
        BasicMetadataBuilder,
        SpatialBuilder,
        DateBuilder,
        ReferencesBuilder,
        LayerInfoBuilder,
        SlugBuilder
      ]

      # Class used to generate urls for links in the document.
      self.root_path_class = DocumentPath

      def initialize(geo_concern, document)
        @geo_concern = geo_concern
        @document = document
        builders.build(document)
      end

      attr_reader :geo_concern, :document
      delegate :to_json, :to_xml, :to_hash, to: :document

      private

        # Instantiates a CompositeBuilder object with an array of
        # builder instances that are used to create the document.
        # @return [CompositeBuilder] composite builder for document
        def builders
          @builders ||= CompositeBuilder.new(
            services.map { |service| service.new(geo_concern) }
          )
        end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
geo_works-0.2.0 app/services/geo_works/discovery/document_builder.rb
geo_works-0.1.4 app/services/geo_works/discovery/document_builder.rb
geo_works-0.1.3 app/services/geo_works/discovery/document_builder.rb
geo_works-0.1.2 app/services/geo_works/discovery/document_builder.rb
geo_works-0.1.1 app/services/geo_works/discovery/document_builder.rb
geo_works-0.1.0 app/services/geo_works/discovery/document_builder.rb