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`)

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

    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`)

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

    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`)

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

    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