Top Level Namespace

Defined Under Namespace

Classes: CGI, Hayabusa

Instance Method Summary collapse

Instance Method Details

#_(str) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kernel_ext/gettext_methods.rb', line 3

def _(str)
  thread = Thread.current
  thread_hayabusa = thread[:hayabusa]
  raise "Could not register Hayabusa-data." if !thread_hayabusa
  hb = thread_hayabusa[:hb]
  raise "Could not register Hayabusa." if !hb
  raise "'gettext' not enabled for Hayabusa." if !hb.gettext
  
  session = thread_hayabusa[:session].sess_data if thread_hayabusa[:session]
  locale = nil
  
  if !thread[:locale].to_s.empty?
    locale = thread[:locale]
  elsif session and !session[:locale].to_s.strip.empty?
    locale = session[:locale]
  elsif hb and !hb.config[:locale_default].to_s.strip.empty?
    session[:locale] = hb.config[:locale_default] if session
    locale = hb.config[:locale_default]
  elsif !session and !hb
    return str
  else
    raise "No locale set for session and ':locale_default' not set in config."
  end
  
  return hb.gettext.trans(locale, str)
end

#_bufObject

This function makes it possible to define methods in ERubis-parsed files (else _buf-variable wouldnt be globally available).



63
64
65
# File 'lib/kernel_ext/magic_methods.rb', line 63

def _buf
  return $stdout
end


1
2
3
# File 'lib/kernel_ext/magic_methods.rb', line 1

def _cookie
  return Thread.current[:hayabusa][:cookie] if Thread.current[:hayabusa]
end

#_dbObject



57
58
59
60
# File 'lib/kernel_ext/magic_methods.rb', line 57

def _db
  return Thread.current[:hayabusa][:db] if Thread.current[:hayabusa] and Thread.current[:hayabusa][:db] #This is the default use from a .rhtml-file.
  return Thread.current[:hayabusa][:hb].db_handler if Thread.current[:hayabusa] and Thread.current[:hayabusa][:hb] #This is useually used when using autoload-argument for the appserver.
end

#_getObject



5
6
7
# File 'lib/kernel_ext/magic_methods.rb', line 5

def _get
  return Thread.current[:hayabusa][:get] if Thread.current[:hayabusa]
end

#_hbObject



49
50
51
# File 'lib/kernel_ext/magic_methods.rb', line 49

def _hb
  return Thread.current[:hayabusa][:hb] if Thread.current[:hayabusa]
end

#_httpsessionObject



33
34
35
# File 'lib/kernel_ext/magic_methods.rb', line 33

def _httpsession
  return Thread.current[:hayabusa][:httpsession] if Thread.current[:hayabusa]
end

#_httpsession_varObject



37
38
39
# File 'lib/kernel_ext/magic_methods.rb', line 37

def _httpsession_var
  return Thread.current[:hayabusa][:httpsession].httpsession_var if Thread.current[:hayabusa]
end

#_metaObject



13
14
15
# File 'lib/kernel_ext/magic_methods.rb', line 13

def _meta
  return Thread.current[:hayabusa][:meta] if Thread.current[:hayabusa]
end

#_postObject



9
10
11
# File 'lib/kernel_ext/magic_methods.rb', line 9

def _post
  return Thread.current[:hayabusa][:post] if Thread.current[:hayabusa]
end

#_request_hashObject



45
46
47
# File 'lib/kernel_ext/magic_methods.rb', line 45

def _request_hash
  return Thread.current[:hayabusa][:httpsession].request_hash if Thread.current[:hayabusa]
end

#_requestdataObject



41
42
43
# File 'lib/kernel_ext/magic_methods.rb', line 41

def _requestdata
  return Thread.current[:hayabusa] if Thread.current[:hayabusa]
end

#_serverObject



17
18
19
# File 'lib/kernel_ext/magic_methods.rb', line 17

def _server
  return Thread.current[:hayabusa][:meta] if Thread.current[:hayabusa]
end

#_sessionObject



21
22
23
# File 'lib/kernel_ext/magic_methods.rb', line 21

def _session
  return Thread.current[:hayabusa][:session].sess_data if Thread.current[:hayabusa] and Thread.current[:hayabusa][:session]
end

#_session_hashObject



25
26
27
# File 'lib/kernel_ext/magic_methods.rb', line 25

def _session_hash
  return Thread.current[:hayabusa][:session].edata if Thread.current[:hayabusa] and Thread.current[:hayabusa][:session]
end

#_session_objObject



29
30
31
# File 'lib/kernel_ext/magic_methods.rb', line 29

def _session_obj
  return Thread.current[:hayabusa][:session] if Thread.current[:hayabusa] and Thread.current[:hayabusa][:session]
end

#_varsObject



53
54
55
# File 'lib/kernel_ext/magic_methods.rb', line 53

def _vars
  return Thread.current[:hayabusa][:hb].vars if Thread.current[:hayabusa]
end