Class: VertxWeb::TemplateHandler

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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 (::VertxWeb::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)


59
60
61
62
63
64
65
66
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_handler.rb', line 59

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::IoVertxExtWebTempl::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::IoVertxExtWebTempl::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) j_api_type



30
31
32
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/vertx-web/template_handler.rb', line 24

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

Instance Method Details

- (void) handle(arg0 = nil)

This method returns an undefined value.

Parameters:

Raises:

  • (ArgumentError)


38
39
40
41
42
43
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_handler.rb', line 38

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

- (self) set_index_template(indexTemplate = nil)

Set the index template

Parameters:

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

Returns:

  • (self)

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/template_handler.rb', line 47

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