Class: VertxMail::MailClient

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb

Overview

SMTP mail client for Vert.x

A simple asynchronous API for sending mails from Vert.x applications

Direct Known Subclasses

MailService

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


20
21
22
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 20

def @@j_api_type.accept?(obj)
  obj.class == MailClient
end

+ (::VertxMail::MailClient) create_non_shared(vertx = nil, config = nil)

create a non shared instance of the mail client

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance the operation will be run in
  • config (Hash) (defaults to: nil)
    MailConfig configuration to be used for sending mails

Returns:

Raises:

  • (ArgumentError)


39
40
41
42
43
44
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 39

def self.create_non_shared(vertx=nil,config=nil)
  if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtMail::MailClient.java_method(:createNonShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtMail::MailConfig.java_class]).call(vertx.j_del,Java::IoVertxExtMail::MailConfig.new(::Vertx::Util::Utils.to_json_object(config))),::VertxMail::MailClient)
  end
  raise ArgumentError, "Invalid arguments when calling create_non_shared(#{vertx},#{config})"
end

+ (::VertxMail::MailClient) create_shared(vertx = nil, config = nil, poolName = nil)

Create a Mail client which shares its connection pool with any other Mail clients created with the same pool name

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vert.x instance
  • config (Hash) (defaults to: nil)
    the configuration
  • poolName (String) (defaults to: nil)
    the pool name

Returns:

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 51

def self.create_shared(vertx=nil,config=nil,poolName=nil)
  if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given? && poolName == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtMail::MailClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtMail::MailConfig.java_class]).call(vertx.j_del,Java::IoVertxExtMail::MailConfig.new(::Vertx::Util::Utils.to_json_object(config))),::VertxMail::MailClient)
  elsif vertx.class.method_defined?(:j_del) && config.class == Hash && poolName.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtMail::MailClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtMail::MailConfig.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,Java::IoVertxExtMail::MailConfig.new(::Vertx::Util::Utils.to_json_object(config)),poolName),::VertxMail::MailClient)
  end
  raise ArgumentError, "Invalid arguments when calling create_shared(#{vertx},#{config},#{poolName})"
end

+ (Object) DEFAULT_POOL_NAME

The name of the default pool


79
80
81
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 79

def self.DEFAULT_POOL_NAME
  Java::IoVertxExtMail::MailClient.DEFAULT_POOL_NAME
end

+ (Object) j_api_type



29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 29

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 32

def self.j_class
  Java::IoVertxExtMail::MailClient.java_class
end

+ (Object) unwrap(obj)



26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 26

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 23

def @@j_api_type.wrap(obj)
  MailClient.new(obj)
end

Instance Method Details

- (void) close

This method returns an undefined value.

close the MailClient

Raises:

  • (ArgumentError)


72
73
74
75
76
77
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 72

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) { ... }

send a single mail via MailClient

Parameters:

  • email (Hash) (defaults to: nil)
    MailMessage object containing the mail text, from/to, attachments etc

Yields:

  • will be called when the operation is finished or it fails (may be null to ignore the result)

Returns:

  • (self)

Raises:

  • (ArgumentError)


63
64
65
66
67
68
69
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-mail/mail_client.rb', line 63

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