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)


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

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

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

Create a handler

Overloads:

Returns:



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

def self.create(*args)
  if args[0].class.method_defined?(:j_del) && !block_given? && args[1] == nil && args[2] == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandler::TemplateHandler.java_method(:create, [Java::IoVertxExtWebCommonTemplate::TemplateEngine.java_class]).call(args[0].j_del),::VertxWeb::TemplateHandler)
  elsif args[0].class.method_defined?(:j_del) && args[1].class == String && args[2].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(args[0].j_del,args[1],args[2]),::VertxWeb::TemplateHandler)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling create(#{args[0]},#{args[1]},#{args[2]})"
  end
end

+ (Object) DEFAULT_CONTENT_TYPE

The default content type header to be used in the response


91
92
93
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 91

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

+ (Object) DEFAULT_INDEX_TEMPLATE

The default index page


95
96
97
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 95

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


87
88
89
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 87

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

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (void) handle(event)

This method returns an undefined value.

Something has happened, so handle it.

Parameters:



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

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

- (self) setIndexTemplate(indexTemplate)

Set the index template

Parameters:

  • indexTemplate (String)
    the index template

Returns:

  • (self)


75
76
77
78
79
80
81
82
83
84
85
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/template_handler.rb', line 75

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