Class: RubyApp::Session
Defined Under Namespace
Classes: Identity
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
method_missing
localize, translate
#configure
#method_missing
Constructor Details
#initialize(page = nil) ⇒ Session
Returns a new instance of Session.
33
34
35
36
37
38
39
|
# File 'lib/ruby_app/session.rb', line 33
def initialize(page = nil)
require 'ruby_app/elements/pages/default_page'
@pages = [ page || RubyApp::Elements::Pages::DefaultPage.new ]
@dialogs = []
@identity = nil
@data = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class RubyApp::Mixins::HashMixin
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
31
32
33
|
# File 'lib/ruby_app/session.rb', line 31
def data
@data
end
|
#identity ⇒ Object
Returns the value of attribute identity.
31
32
33
|
# File 'lib/ruby_app/session.rb', line 31
def identity
@identity
end
|
#pages ⇒ Object
Returns the value of attribute pages.
30
31
32
|
# File 'lib/ruby_app/session.rb', line 30
def pages
@pages
end
|
Class Method Details
.create! ⇒ Object
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/ruby_app/session.rb', line 78
def self.create!
Thread.current[:_session] = RubyApp::Request.session[:_session] ||= RubyApp::Application.options.session_class.new
if block_given?
begin
yield
ensure
self.destroy!
end
end
end
|
.destroy! ⇒ Object
89
90
91
|
# File 'lib/ruby_app/session.rb', line 89
def self.destroy!
Thread.current[:_session] = nil
end
|
.get ⇒ Object
74
75
76
|
# File 'lib/ruby_app/session.rb', line 74
def self.get
Thread.current[:_session]
end
|
Instance Method Details
#[](key) ⇒ Object
41
42
43
|
# File 'lib/ruby_app/session.rb', line 41
def [](key)
@data[key]
end
|
#[]=(key, value) ⇒ Object
45
46
47
|
# File 'lib/ruby_app/session.rb', line 45
def []=(key, value)
@data[key] = value
end
|
#quit ⇒ Object
70
71
72
|
# File 'lib/ruby_app/session.rb', line 70
def quit
RubyApp::Request.env['rack.session.options'][:drop] = true
end
|
#show(event, dialog, &block) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/ruby_app/session.rb', line 49
def show(event, dialog, &block)
@dialogs.push(dialog)
if block_given? and block.arity == 1
dialog.shown do |element, _event|
yield _event
_event.hide(element)
end
end
dialog.hidden do |element, _event|
if block_given? and block.arity == 2
yield _event, dialog.response
end
@dialogs.delete(dialog)
end
event.show(dialog)
end
|