Class: VertxWeb::TemplateHandler

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

Overview

A handler which renders responses using a template engine and where the template name is selected from the URI path.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

21
22
23
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 21

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

+ (::VertxWeb::TemplateHandler) create(engine = nil, templateDirectory = nil, contentType = nil)

Create a handler

Parameters:

  • engine (::VertxWebCommon::TemplateEngine) (defaults to: nil)
    the template engine
  • templateDirectory (String) (defaults to: nil)
    the template directory where templates will be looked for
  • contentType (String) (defaults to: nil)
    the content type header to be used in the response

Returns:

Raises:

  • (ArgumentError)

60
61
62
63
64
65
66
67
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 60

def self.create(engine=nil,templateDirectory=nil,contentType=nil)
  if engine.class.method_defined?(:j_del) && !block_given? && templateDirectory == nil && contentType == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::TemplateHandler.java_method(:create, [Java::IoVertxExtWebCommonTemplate::TemplateEngine.java_class]).call(engine.j_del),::VertxWeb::TemplateHandler)
  elsif engine.class.method_defined?(:j_del) && templateDirectory.class == String && contentType.class == String && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::TemplateHandler.java_method(:create, [Java::IoVertxExtWebCommonTemplate::TemplateEngine.java_class,Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(engine.j_del,templateDirectory,contentType),::VertxWeb::TemplateHandler)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{engine},#{templateDirectory},#{contentType})"
end

+ (Object) DEFAULT_CONTENT_TYPE

The default content type header to be used in the response

73
74
75
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 73

def self.DEFAULT_CONTENT_TYPE
  Java::IoVertxExtWebHandler::TemplateHandler.DEFAULT_CONTENT_TYPE
end

+ (Object) DEFAULT_INDEX_TEMPLATE

The default index page

77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 77

def self.DEFAULT_INDEX_TEMPLATE
  Java::IoVertxExtWebHandler::TemplateHandler.DEFAULT_INDEX_TEMPLATE
end

+ (Object) DEFAULT_TEMPLATE_DIRECTORY

The default directory where templates will be looked for

69
70
71
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 69

def self.DEFAULT_TEMPLATE_DIRECTORY
  Java::IoVertxExtWebHandler::TemplateHandler.DEFAULT_TEMPLATE_DIRECTORY
end

+ (Object) j_api_type


30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 30

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


33
34
35
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 33

def self.j_class
  Java::IoVertxExtWebHandler::TemplateHandler.java_class
end

+ (Object) unwrap(obj)


27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 27

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

+ (Object) wrap(obj)


24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 24

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

Instance Method Details

- (void) handle(event = nil)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:

Raises:

  • (ArgumentError)

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

def handle(event=nil)
  if event.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(event.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling handle(#{event})"
end

- (self) set_index_template(indexTemplate = nil)

Set the index template

Parameters:

  • indexTemplate (String) (defaults to: nil)
    the index template

Returns:

  • (self)

Raises:

  • (ArgumentError)

48
49
50
51
52
53
54
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 48

def set_index_template(indexTemplate=nil)
  if indexTemplate.class == String && !block_given?
    @j_del.java_method(:setIndexTemplate, [Java::java.lang.String.java_class]).call(indexTemplate)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_index_template(#{indexTemplate})"
end