Class: Swiftype::Engine

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/swiftype/engine.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

collection_name, #create!, #destroy!, #id, #identifier, model_name, parents, #path_to_collection, #path_to_model, #raw_path_to_collection, #raw_path_to_model, #reload, #slugged?, #to_hash, #to_json, #update!, #update_with!

Methods included from Request

#delete, #get, #post, #put

Methods included from Connection

#connection

Class Method Details

.find(id) ⇒ Object



3
4
5
# File 'lib/swiftype/engine.rb', line 3

def self.find(id)
  new Swiftype::Client.new.get("engines/#{id}.json")
end

Instance Method Details

#build_document_type(params = {}) ⇒ Object



7
8
9
10
11
# File 'lib/swiftype/engine.rb', line 7

def build_document_type(params={})
  DocumentType.new({
    :engine_id => id
  }.merge(params))
end

#create_document_type(params = {}) ⇒ Object



13
14
15
16
17
# File 'lib/swiftype/engine.rb', line 13

def create_document_type(params={})
  doc = build_document_type(params)
  doc.create!
  doc
end

#destroy_document_type(document_type_name) ⇒ Object



19
20
21
22
23
# File 'lib/swiftype/engine.rb', line 19

def destroy_document_type(document_type_name)
  !!delete("engines/#{slug}/document_types/#{document_type_name}")
rescue NonExistentRecord
  false
end

#document_type(id) ⇒ Object



25
26
27
# File 'lib/swiftype/engine.rb', line 25

def document_type(id)
  DocumentType.new get("engines/#{slug}/document_types/#{id}.json")
end

#document_typesObject



29
30
31
# File 'lib/swiftype/engine.rb', line 29

def document_types
  get("engines/#{slug}/document_types.json").map { |dt| DocumentType.new(dt) }
end