Class: VertxWeb::Session

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

Overview

Represents a browser session.

Sessions persist between HTTP requests for a single browser session. They are deleted when the browser is closed, or they time-out. Session cookies are used to maintain sessions using a secure UUID.

Sessions can be used to maintain data for a browser session, e.g. a shopping basket.

The context must have first been routed to a SessionHandler for sessions to be available.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



37
38
39
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 37

def self.j_class
  Java::IoVertxExtWeb::Session.java_class
end

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (void) destroy

This method returns an undefined value.

Destroy the session

Raises:

  • (ArgumentError)


99
100
101
102
103
104
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 99

def destroy
  if !block_given?
    return @j_del.java_method(:destroy, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling destroy()"
end

- (true, false) destroyed?

Returns has the session been destroyed?

Returns:

  • (true, false)
    has the session been destroyed?

Raises:

  • (ArgumentError)


106
107
108
109
110
111
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 106

def destroyed?
  if !block_given?
    return @j_del.java_method(:isDestroyed, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling destroyed?()"
end

- (true, false) empty?

Returns true if the session has data

Returns:

  • (true, false)
    true if the session has data

Raises:

  • (ArgumentError)


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

def empty?
  if !block_given?
    return @j_del.java_method(:isEmpty, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling empty?()"
end

- (Object) get(key = nil)

Get some data from the session

Parameters:

  • key (String) (defaults to: nil)
    the key of the data

Returns:

  • (Object)
    the data

Raises:

  • (ArgumentError)


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

def get(key=nil)
  if key.class == String && !block_given?
    return ::Vertx::Util::Utils.from_object(@j_del.java_method(:get, [Java::java.lang.String.java_class]).call(key))
  end
  raise ArgumentError, "Invalid arguments when calling get(#{key})"
end

- (String) id

Returns The unique ID of the session. This is generated using a random secure UUID.

Returns:

  • (String)
    The unique ID of the session. This is generated using a random secure UUID.

Raises:

  • (ArgumentError)


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

def id
  if !block_given?
    return @j_del.java_method(:id, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling id()"
end

- (Fixnum) last_accessed

Returns the time the session was last accessed

Returns:

  • (Fixnum)
    the time the session was last accessed

Raises:

  • (ArgumentError)


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

def last_accessed
  if !block_given?
    return @j_del.java_method(:lastAccessed, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling last_accessed()"
end

- (String) old_id

Returns old ID if renewed

Returns:

  • (String)
    old ID if renewed

Raises:

  • (ArgumentError)


120
121
122
123
124
125
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 120

def old_id
  if !block_given?
    return @j_del.java_method(:oldId, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling old_id()"
end

- (self) put(key = nil, obj = nil)

Put some data in a session

Parameters:

  • key (String) (defaults to: nil)
    the key for the data
  • obj (Object) (defaults to: nil)
    the data

Returns:

  • (self)

Raises:

  • (ArgumentError)


58
59
60
61
62
63
64
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 58

def put(key=nil,obj=nil)
  if key.class == String && ::Vertx::Util::unknown_type.accept?(obj) && !block_given?
    @j_del.java_method(:put, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class]).call(key,::Vertx::Util::Utils.to_object(obj))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling put(#{key},#{obj})"
end

- (::VertxWeb::Session) regenerate_id

Returns The new unique ID of the session.

Returns:

Raises:

  • (ArgumentError)


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

def regenerate_id
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:regenerateId, []).call(),::VertxWeb::Session)
  end
  raise ArgumentError, "Invalid arguments when calling regenerate_id()"
end

- (true, false) regenerated?

Returns has the session been renewed?

Returns:

  • (true, false)
    has the session been renewed?

Raises:

  • (ArgumentError)


113
114
115
116
117
118
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 113

def regenerated?
  if !block_given?
    return @j_del.java_method(:isRegenerated, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling regenerated?()"
end

- (Object) remove(key = nil)

Remove some data from the session

Parameters:

  • key (String) (defaults to: nil)
    the key of the data

Returns:

  • (Object)
    the data that was there or null if none there

Raises:

  • (ArgumentError)


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

def remove(key=nil)
  if key.class == String && !block_given?
    return ::Vertx::Util::Utils.from_object(@j_del.java_method(:remove, [Java::java.lang.String.java_class]).call(key))
  end
  raise ArgumentError, "Invalid arguments when calling remove(#{key})"
end

- (void) set_accessed

This method returns an undefined value.

Mark the session as being accessed.

Raises:

  • (ArgumentError)


135
136
137
138
139
140
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 135

def set_accessed
  if !block_given?
    return @j_del.java_method(:setAccessed, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling set_accessed()"
end

- (Fixnum) timeout

Returns the amount of time in ms, after which the session will expire, if not accessed.

Returns:

  • (Fixnum)
    the amount of time in ms, after which the session will expire, if not accessed.

Raises:

  • (ArgumentError)


127
128
129
130
131
132
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 127

def timeout
  if !block_given?
    return @j_del.java_method(:timeout, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling timeout()"
end

- (String) value

The short representation of the session to be added to the session cookie. By default is the session id.

Returns:

  • (String)
    short representation string.

Raises:

  • (ArgumentError)


143
144
145
146
147
148
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/session.rb', line 143

def value
  if !block_given?
    return @j_del.java_method(:value, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling value()"
end