Sha256: 7c81bd492d36c61760cf55b48185fe83cfdb7c150c2a25338a9f09654a1156f0

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 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 [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
        request_config['request_url']
      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(
          request_config['request_mappings']
        )
      end

      def title
        presenter.heading
      end

      def request_config
        document.repository_config&.request_config_for_type('google_form')
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
arclight-1.4.0 app/models/arclight/requests/google_form.rb
arclight-1.3.0 app/models/arclight/requests/google_form.rb
arclight-1.2.0 app/models/arclight/requests/google_form.rb
arclight-1.1.3 app/models/arclight/requests/google_form.rb
arclight-1.1.2 app/models/arclight/requests/google_form.rb
arclight-1.1.1 app/models/arclight/requests/google_form.rb
arclight-1.1.0 app/models/arclight/requests/google_form.rb
arclight-1.0.1 app/models/arclight/requests/google_form.rb
arclight-1.0.0 app/models/arclight/requests/google_form.rb
arclight-1.0.0.beta6 app/models/arclight/requests/google_form.rb
arclight-1.0.0.beta4 app/models/arclight/requests/google_form.rb
arclight-1.0.0.beta3 app/models/arclight/requests/google_form.rb
arclight-1.0.0.beta2 app/models/arclight/requests/google_form.rb
arclight-1.0.0.beta1 app/models/arclight/requests/google_form.rb