Class: Wit::REST::MultiEntity

Inherits:
Result
  • Object
show all
Defined in:
lib/wit_ruby/rest/entity.rb

Overview

TODO:

Propagate these methods into Result

Wrapper for array of entities as strings. Inherits from Results so it can be refreshed.

Instance Method Summary collapse

Methods inherited from Result

#empty?, #entities, #method_missing, #raw_data, #refreshable?, #restBody, #restCode, #restPath

Constructor Details

#initialize(resultData, requestRest = nil, requestPath = nil, requestBody = nil) ⇒ Wit::REST::MultiIntent

Generates instance variable that holds list of entities as strings in array.

Parameters:

  • resultData (Hash)

    data from the call.

  • requestRest (String) (defaults to: nil)

    rest code for the call.

  • requestPath (String) (defaults to: nil)

    request path for the call.

  • requestBody (Hash) (defaults to: nil)

    body of the call.



48
49
50
51
52
# File 'lib/wit_ruby/rest/entity.rb', line 48

def initialize(resultData, requestRest=nil, requestPath=nil, requestBody=nil)
  ## Pass in empty hash to default to method missing for everything not defined here.
  super({}, requestRest, requestPath, requestBody)
  @entities = resultData
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wit::REST::Result

Instance Method Details

#[](num) ⇒ Wit::REST::Result

Overide that assists in calling the proper index in the array of entity strings.

Parameters:

  • num (Integer)

    index of the array of Strings

Returns:



58
59
60
# File 'lib/wit_ruby/rest/entity.rb', line 58

def [](num)
  @entities[num]
end

#eachString

Assists in going through each entity string in the instance variable.

Returns:

  • (String)

    lambda that provides each specific entity id.



65
66
67
68
69
# File 'lib/wit_ruby/rest/entity.rb', line 65

def each
  @entities.each do |entity|
    lambda{entity}
  end
end