Class: WitBot::WitModelRequest

Inherits:
WitRequest show all
Defined in:
lib/wit_bot/requests/models/wit_model_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from WitRequest

#http, #request

Constructor Details

#initialize(model: nil) ⇒ WitModelRequest

Returns a new instance of WitModelRequest.



11
12
13
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 11

def initialize(model: nil)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 3

def model
  @model
end

Instance Method Details

#createObject



20
21
22
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 20

def create
  request http.post(model_path, json: model.as_json)
end

#deleteObject



28
29
30
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 28

def delete
  request http.delete("#{model_path}/#{model.name}")
end

#get(all: false) ⇒ Object



15
16
17
18
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 15

def get(all: false)
  path = all ? model_path : individual_model_path
  request http.get path
end

#individual_model_pathObject



7
8
9
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 7

def individual_model_path
  "#{model_path}/#{@model.name || @model.id}"
end

#model_pathObject



5
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 5

def model_path; end

#updateObject



24
25
26
# File 'lib/wit_bot/requests/models/wit_model_request.rb', line 24

def update
  request http.put(model_path, json: model.as_json)
end