Sha256: a51479724f4a23406d617fb5794c09404cb8a3a90770961bb0b0f9884406eae7

Contents?: true

Size: 631 Bytes

Versions: 10

Compression:

Stored size: 631 Bytes

Contents

require 'json'
module Inquisitio
  class Document

    attr_reader :type, :id, :version, :fields

    def initialize(type, id, version, fields)
      @type = type
      @id = id
      @version = version
      @fields = fields.reject { |k, v| v.nil? }
    end

    def to_SDF
      if Inquisitio.config.api_version == '2011-02-01'
        "{ \"type\": \"#{type}\", \"id\": \"#{id}\", \"version\": #{version}, \"lang\": \"en\", \"fields\": #{fields.to_json} }"
      elsif Inquisitio.config.api_version == '2013-01-01'
        "{ \"type\": \"#{type}\", \"id\": \"#{id}\", \"fields\": #{fields.to_json} }"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
inquisitio-1.5.0 lib/inquisitio/document.rb
inquisitio-1.4.1 lib/inquisitio/document.rb
inquisitio-1.4.0 lib/inquisitio/document.rb
inquisitio-1.3.1 lib/inquisitio/document.rb
inquisitio-1.3.0 lib/inquisitio/document.rb
inquisitio-1.2.4 lib/inquisitio/document.rb
inquisitio-1.2.3 lib/inquisitio/document.rb
inquisitio-1.2.2 lib/inquisitio/document.rb
inquisitio-1.2.1 lib/inquisitio/document.rb
inquisitio-1.2.0 lib/inquisitio/document.rb