Class List Method List File List

# Class: VertxMail::MailService

Inherits:
  MailClient
  - Object
  - MailClient
  - VertxMail::MailService
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-mail-client/vertx-mail-service/src/main/resources/vertx-mail/mail_service.rb

## Overview

@author Tim Fox

## Class Method Summary (collapse)

- + (::VertxMail::MailService) create_event_bus_proxy(vertx = nil, address = nil)
  create a proxy of MailService that delegates to the mail service running somewhere else via the event bus.

## Instance Method Summary (collapse)

- - (void) close
- - (self) send_mail(email = nil) { ... }

### Methods inherited from MailClient

create_non_shared, create_shared

## Class Method Details

### + (`::VertxMail::MailService`) create_event_bus_proxy(vertx = nil, address = nil)

create a proxy of MailService that delegates to the mail service running somewhere else via the event bus

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the Vertx instance the proxy will be run in
- address (`String`) (defaults to: `nil`) —
  the eb address of the mail service running somewhere, default is "vertx.mail"

Returns:

- (`::VertxMail::MailService`) —
  MailService instance that can then be used to send multiple mails

Raises:

- (`ArgumentError`)

    22
    23
    24
    25
    26
    27
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/vertx-mail-service/src/main/resources/vertx-mail/mail_service.rb', line 22

    def self.create_event_bus_proxy(vertx=nil,address=nil)
      if vertx.class.method_defined?(:j_del) && address.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtMail::MailService.java_method(:createEventBusProxy, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,address),::VertxMail::MailService)
      end
      raise ArgumentError, "Invalid arguments when calling create_event_bus_proxy(vertx,address)"
    end

## Instance Method Details

### - (`void`) close

This method returns an undefined value.

Raises:

- (`ArgumentError`)

    39
    40
    41
    42
    43
    44
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/vertx-mail-service/src/main/resources/vertx-mail/mail_service.rb', line 39

    def close
      if !block_given?
        return @j_del.java_method(:close, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling close()"
    end

### - (`self`) send_mail(email = nil) { ... }

Parameters:

- email (`Hash`) (defaults to: `nil`)

Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    31
    32
    33
    34
    35
    36
    37
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/vertx-mail-service/src/main/resources/vertx-mail/mail_service.rb', line 31

    def send_mail(email=nil)
      if email.class == Hash && block_given?
        @j_del.java_method(:sendMail, [Java::IoVertxExtMail::MailMessage.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxExtMail::MailMessage.new(::Vertx::Util::Utils.to_json_object(email)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.toJson.encode) : nil : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling send_mail(email)"
    end