Module: Card::Env
Overview
Card::Env can differ for each request; Card.config should not
Defined Under Namespace
Modules: LocationHistory
Class Method Summary
collapse
discard_locations_for, interrupted_action, location_history, previous_location, save_interrupted_action, save_location, save_location?, url_key_for_location
Class Method Details
24
25
26
|
# File 'lib/card/env.rb', line 24
def [] key
@@env[key.to_sym]
end
|
.[]=(key, value) ⇒ Object
28
29
30
|
# File 'lib/card/env.rb', line 28
def []= key, value
@@env[key.to_sym] = value
end
|
.ajax? ⇒ Boolean
48
49
50
|
# File 'lib/card/env.rb', line 48
def ajax?
self[:ajax]
end
|
.html? ⇒ Boolean
52
53
54
|
# File 'lib/card/env.rb', line 52
def html?
!self[:controller] || self[:html]
end
|
.localhost? ⇒ Boolean
44
45
46
|
# File 'lib/card/env.rb', line 44
def localhost?
self[:host] && self[:host] =~ /^localhost/
end
|
.method_missing(method_id, *args) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/card/env.rb', line 56
def method_missing method_id, *args
case args.length
when 0 then self[method_id]
when 1 then self[method_id] = args[0]
else super
end
end
|
32
33
34
|
# File 'lib/card/env.rb', line 32
def params
self[:params] ||= {}
end
|
.reset(args = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/card/env.rb', line 7
def reset args={}
@@env = { main_name: nil }
if (c = args[:controller])
self[:controller] = c
self[:session] = c.request.session
self[:params] = c.params
self[:ip] = c.request.remote_ip
self[:ajax] = c.request.xhr? || c.request.params[:simulate_xhr]
self[:html] = [nil, 'html'].member?(c.params[:format])
self[:host] = Card.config.override_host ||
c.request.env['HTTP_HOST']
self[:protocol] = Card.config.override_protocol ||
c.request.protocol
end
end
|
36
37
38
|
# File 'lib/card/env.rb', line 36
def session
self[:session] ||= {}
end
|
.success(cardname = nil) ⇒ Object
40
41
42
|
# File 'lib/card/env.rb', line 40
def success cardname=nil
self[:success] ||= Card::Success.new(cardname, params[:success])
end
|