Method: ApiAiWrapper::Engine#initialize
- Defined in:
- lib/api_ai_wrapper/engine.rb
#initialize(options = {}) ⇒ Engine
Returns a new instance of Engine.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/api_ai_wrapper/engine.rb', line 19 def initialize( = {}) self.client = HTTPClient.new self.client.receive_timeout = [:client_timeout].presence || ApiAiWrapper::Constants::DEFAULT_CLIENT_TIMEOUT self.locale = [:locale].presence || ApiAiWrapper::Constants::DEFAULT_LOCALE self.base_url = ApiAiWrapper::Constants::DEFAULT_BASE_URL self.version = [:version].presence || ApiAiWrapper::Constants::DEFAULT_VERSION self.client_token = [:client_token].presence self.developer_token = [:developer_token].presence # RAISE ERROR IF NO TOKEN PRESENT raise ApiAiWrapper::Errors::Engine::MissingTokens.new if self.client_token.blank? && self.developer_token.blank? # define entity_trainer and intent_trainer on the fly AUTOLOAD_CLASSES.each{ |class_name| instance = class_name.new instance.engine = self self.send("#{class_name.to_s.demodulize.underscore}=", instance) } end |