Sha256: 400458089e052da77d1ee79b216bc3c10e731dcd5eae9ee911432cfce38f3fce

Contents?: true

Size: 922 Bytes

Versions: 8

Compression:

Stored size: 922 Bytes

Contents

module Nazrin
  class DocumentClient
    attr_reader :client

    def initialize
      @client = Aws::CloudSearchDomain::Client.new(
        endpoint: Nazrin.config.document_endpoint,
        region: Nazrin.config.region,
        access_key_id: Nazrin.config.access_key_id,
        secret_access_key: Nazrin.config.secret_access_key)
    end

    def add_document(id, field_data)
      return nil if Nazrin.config.debug_mode
      client.upload_documents(
        documents: [
          {
            type: 'add',
            id: id,
            fields: field_data
          }
        ].to_json,
        content_type: 'application/json')
    end

    def delete_document(id)
      return nil if Nazrin.config.debug_mode
      client.upload_documents(
        documents: [
          {
            type: 'delete',
            id: id
          }
        ].to_json,
        content_type: 'application/json')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nazrin-2.0.0 lib/nazrin/document_client.rb
nazrin-2.0.0.rc2 lib/nazrin/document_client.rb
nazrin-2.0.0.rc1 lib/nazrin/document_client.rb
nazrin-1.0.1 lib/nazrin/document_client.rb
nazrin-1.0.0 lib/nazrin/document_client.rb
nazrin-0.2.0 lib/nazrin/document_client.rb
nazrin-0.1.1 lib/nazrin/document_client.rb
nazrin-0.1.0 lib/nazrin/document_client.rb