Sha256: 1221fd656dc524a7a21e1a159730f0ce854bf7646982956d71b0b94f03de31ee

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Arclight
  module Requests
    ##
    # This object relies on the ability to respond to attributes passed in as
    # query parameters from the form mapping configuratino
    class GoogleForm
      attr_reader :document, :presenter, :document_url
      delegate :collection_name, :collection_creator, :eadid, :containers, to: :document

      ##
      # @param [Blacklight::SolrDocument] document
      # @param [Arclight::ShowPresenter] presenter
      # @param [String] document_url
      def initialize(document, presenter, document_url)
        @document = document
        @presenter = presenter
        @document_url = document_url
      end

      ##
      # Url of form to fill
      def url
        document.repository_config&.request_url_for_type('google_form')
      end

      ##
      # Converts mappings as a query url param into a Hash used for sending
      # messages and providing pre-filled form fields
      # "collection_name=entry.123" => { "collection_name" => "entry.123" }
      # @return [Hash]
      def form_mapping
        Rack::Utils.parse_nested_query(
          document.repository_config&.request_mappings_for_type('google_form')
        )
      end

      def title
        presenter.heading
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
arclight-0.5.0 app/models/arclight/requests/google_form.rb
arclight-0.4.0 app/models/arclight/requests/google_form.rb
arclight-0.3.3 app/models/arclight/requests/google_form.rb
arclight-0.3.2 app/models/arclight/requests/google_form.rb
arclight-0.3.1 app/models/arclight/requests/google_form.rb
arclight-0.3.0 app/models/arclight/requests/google_form.rb