Module: Twilio::Rails

Defined in:
lib/twilio/rails.rb,
lib/twilio/rails.rb,
lib/twilio/rails/sms.rb,
lib/twilio/rails/phone.rb,
lib/twilio/rails/client.rb,
lib/twilio/rails/engine.rb,
lib/twilio/rails/railtie.rb,
lib/twilio/rails/version.rb,
lib/twilio/rails/formatter.rb,
lib/twilio/rails/phone/tree.rb,
lib/twilio/rails/phone_number.rb,
lib/twilio/rails/configuration.rb,
lib/twilio/rails/sms/responder.rb,
lib/twilio/rails/models/message.rb,
lib/twilio/rails/models/response.rb,
lib/twilio/rails/phone/base_tree.rb,
lib/twilio/rails/models/recording.rb,
lib/twilio/rails/models/phone_call.rb,
lib/twilio/rails/phone/tree_macros.rb,
lib/twilio/rails/models/phone_caller.rb,
app/jobs/twilio/rails/application_job.rb,
lib/twilio/rails/concerns/has_direction.rb,
lib/twilio/rails/models/sms_conversation.rb,
lib/twilio/rails/sms/delegated_responder.rb,
lib/twilio/rails/concerns/has_time_scopes.rb,
app/models/twilio/rails/application_record.rb,
lib/twilio/rails/concerns/has_phone_number.rb,
app/controllers/twilio/rails/sms_controller.rb,
app/helpers/twilio/rails/application_helper.rb,
app/mailers/twilio/rails/application_mailer.rb,
app/controllers/twilio/rails/phone_controller.rb,
app/jobs/twilio/rails/phone/finished_call_job.rb,
app/operations/twilio/rails/sms/base_operation.rb,
app/operations/twilio/rails/sms/find_operation.rb,
app/operations/twilio/rails/sms/send_operation.rb,
app/jobs/twilio/rails/phone/unanswered_call_job.rb,
app/jobs/twilio/rails/phone/attach_recording_job.rb,
app/operations/twilio/rails/phone/base_operation.rb,
app/operations/twilio/rails/phone/find_operation.rb,
app/operations/twilio/rails/sms/create_operation.rb,
app/operations/twilio/rails/application_operation.rb,
app/operations/twilio/rails/phone/create_operation.rb,
app/operations/twilio/rails/phone/update_operation.rb,
app/controllers/twilio/rails/application_controller.rb,
app/operations/twilio/rails/sms/twiml/base_operation.rb,
app/operations/twilio/rails/sms/twiml/error_operation.rb,
app/operations/twilio/rails/phone/start_call_operation.rb,
app/operations/twilio/rails/phone/twiml/base_operation.rb,
app/operations/twilio/rails/sms/find_message_operation.rb,
app/operations/twilio/rails/phone/twiml/after_operation.rb,
app/operations/twilio/rails/phone/twiml/error_operation.rb,
app/operations/twilio/rails/sms/twiml/message_operation.rb,
app/operations/twilio/rails/phone/twiml/prompt_operation.rb,
app/operations/twilio/rails/sms/update_message_operation.rb,
app/operations/twilio/rails/phone/finished_call_operation.rb,
app/operations/twilio/rails/phone/twiml/timeout_operation.rb,
app/operations/twilio/rails/phone/twiml/greeting_operation.rb,
app/operations/twilio/rails/phone/unanswered_call_operation.rb,
app/operations/twilio/rails/phone/update_response_operation.rb,
app/operations/twilio/rails/phone/attach_recording_operation.rb,
app/operations/twilio/rails/phone/receive_recording_operation.rb,
app/operations/twilio/rails/find_or_create_phone_caller_operation.rb,
app/operations/twilio/rails/phone/twiml/prompt_response_operation.rb,
app/operations/twilio/rails/phone/twiml/request_validation_failure_operation.rb

Defined Under Namespace

Modules: ApplicationHelper, Client, Formatter, HasDirection, HasPhoneNumber, HasTimeScopes, Models, Phone, SMS Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationOperation, ApplicationRecord, Configuration, Engine, Error, FindOrCreatePhoneCallerOperation, InstallGenerator, PhoneController, PhoneNumber, PhoneTreeGenerator, Railtie, SMSController, SmsResponderGenerator

Constant Summary collapse

VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.configTwilio::Rails::Configuration

Read and write accessible configuration object. In most cases this should only be read after the app has been initialized. See Configuration for more information.

Returns:



48
49
50
# File 'lib/twilio/rails.rb', line 48

def config
  @config ||= ::Twilio::Rails::Configuration.new
end

.notify_exception(exception, message: nil, context: {}, exception_binding: nil) ⇒ true, false

Abstraction for the framework to notify of an important exception that has occurred. This safely calls the configured ‘config.exception_notifier` or does nothing if it is set to `nil`. This does not catch, handle, or prevent the exception from raising.

Parameters:

  • exception (Exception)

    the exception that has occurred.

  • message (String) (defaults to: nil)

    a description of the exception, defaults to ‘exception.message` if blank.

  • context (Hash) (defaults to: {})

    a hash of arbitrary additional context to include in the notification.

  • exception_binding (Binding) (defaults to: nil)

    the binding of where the exception is being notified.

Returns:

  • (true, false)

    if an exception has been successfully notified.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/twilio/rails.rb', line 73

def notify_exception(exception, message: nil, context: {}, exception_binding: nil)
  if config.exception_notifier
    begin
      message = message.presence || exception.message
      config.exception_notifier.call(exception, message, context, exception_binding)
      true
    rescue => e
      config.logger.tagged(self.class) { |l| l.error("ExceptionNotifier failed to notify of exception=#{ exception.inspect } message=#{ message.inspect } context=#{ context.inspect }") }
      false
    end
  else
    false
  end
end

.setup {|Twilio::Rails::Configuration| ... } ⇒ nil

Called in the ‘config/initializers/twilio_rails.rb` file to configure the engine. This yields the config object above and then calls Twilio::Rails::Configuration#validate! to ensure the configuration is valid.

Yields:

Returns:

  • (nil)


57
58
59
60
61
62
# File 'lib/twilio/rails.rb', line 57

def setup
  config.setup!
  yield(config)
  config.validate!
  nil
end