Class: WelltreatStoreFramework::HamlRenderer::Context
- Inherits:
-
Object
- Object
- WelltreatStoreFramework::HamlRenderer::Context
show all
- Includes:
- Rack::Recaptcha::Helpers, LoremHelper, Partial, Paths, TagsHelper
- Defined in:
- lib/welltreat_store_framework/haml_renderer/context.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Paths
#asset_path, #image_path, #javascript_path, #sprockets_enabled?, #stylesheet_path
Methods included from Partial
#partial
Methods included from TagsHelper
#content_tag, #image_tag, #javascript_include_tag, #link_to, #strip_tags, #stylesheet_link_tag, #truncate
#lorem
Constructor Details
#initialize(app, request, response, options) ⇒ Context
Returns a new instance of Context.
16
17
18
19
20
21
22
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 16
def initialize(app, request, response, options)
@app = app
@request = request
@response = response
@options = options || { }
@locals = { }
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
14
15
16
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 14
def options
@options
end
|
#request ⇒ Object
Returns the value of attribute request.
14
15
16
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 14
def request
@request
end
|
#response ⇒ Object
Returns the value of attribute response.
14
15
16
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 14
def response
@response
end
|
Instance Method Details
#alert ⇒ Object
52
53
54
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 52
def alert
get_flash :alert
end
|
#app ⇒ Object
24
25
26
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 24
def app;
@app
end
|
#flash ⇒ Object
76
77
78
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 76
def flash
options[:session][:flash] ||= { }
end
|
#flash_exist? ⇒ Boolean
60
61
62
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 60
def flash_exist?
notice || alert || success
end
|
#get_flash(k) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 64
def get_flash(k)
@flash_values ||= { }
@flash_values[k] ||= flash[k]
flash[k] = nil if @flash_values[k].present?
@flash_values[k]
end
|
#get_local(k) ⇒ Object
32
33
34
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 32
def get_local(k)
@locals[k]
end
|
#local_exists?(k) ⇒ Boolean
36
37
38
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 36
def local_exists?(k)
@locals.include?(k)
end
|
#local_present?(k) ⇒ Boolean
40
41
42
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 40
def local_present?(k)
local_exists?(k) && get_local(k).present?
end
|
#notice ⇒ Object
48
49
50
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 48
def notice
get_flash :notice
end
|
#session ⇒ Object
44
45
46
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 44
def session
options[:session]
end
|
#set_flash(k, v) ⇒ Object
72
73
74
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 72
def set_flash(k, v)
flash[k] = v
end
|
#set_local(k, v) ⇒ Object
28
29
30
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 28
def set_local(k, v)
@locals[k] = v
end
|
#success ⇒ Object
56
57
58
|
# File 'lib/welltreat_store_framework/haml_renderer/context.rb', line 56
def success
get_flash :success
end
|