Class: Expando::EntityUpdater

Inherits:
Updater
  • Object
show all
Defined in:
lib/expando/entity_updater.rb

Overview

Responsible for updating entity objects on Api.ai based on the contents of files in ‘/entities`.

Constant Summary

Constants inherited from Updater

Updater::DEFAULT_ENTITIES_PATH, Updater::DEFAULT_INTENTS_PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEntityUpdater

Initialize a new ‘EntityUpdater`.

See Also:



16
17
18
# File 'lib/expando/entity_updater.rb', line 16

def initialize( * )
  super
end

Instance Attribute Details

#entities_pathObject

!@attribute entities_path

@return [String] the path to the directory containing the entities text files


11
12
13
# File 'lib/expando/entity_updater.rb', line 11

def entities_path
  @entities_path
end

#nameObject

!@attribute name

@return [String] the name of the entity to be updated


7
8
9
# File 'lib/expando/entity_updater.rb', line 7

def name
  @name
end

Instance Method Details

#update!Hash, ApiAiRuby::RequestError

Update the named entity on Api.ai.

Returns:

  • (Hash)

    if request successful. This is the response body.

  • (ApiAiRuby::RequestError)

    if request is in error.



24
25
26
27
28
29
30
# File 'lib/expando/entity_updater.rb', line 24

def update!
  entity = [{ name: @name.to_s, entries: expanded_entries }]

  response = @client.update_entities_request( entity )

  handle_response( response, :entity )
end