responders 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/responders/flash_responder.rb +17 -16
- data/lib/responders/http_cache_responder.rb +12 -12
- data/lib/responders/version.rb +1 -1
- metadata +2 -2
@@ -87,27 +87,28 @@ module Responders
|
|
87
87
|
|
88
88
|
def to_html
|
89
89
|
super
|
90
|
+
set_flash_message! if set_flash_message?
|
91
|
+
end
|
90
92
|
|
91
|
-
|
92
|
-
if has_errors?
|
93
|
-
controller.flash[:alert] ||= @alert if @alert
|
94
|
-
status = Responders::FlashResponder.flash_keys.last
|
95
|
-
else
|
96
|
-
controller.flash[:notice] ||= @notice if @notice
|
97
|
-
status = Responders::FlashResponder.flash_keys.first
|
98
|
-
end
|
99
|
-
|
100
|
-
return if controller.flash[status].present?
|
93
|
+
protected
|
101
94
|
|
102
|
-
|
103
|
-
|
104
|
-
controller.flash[
|
95
|
+
def set_flash_message!
|
96
|
+
if has_errors?
|
97
|
+
controller.flash[:alert] ||= @alert if @alert
|
98
|
+
status = Responders::FlashResponder.flash_keys.last
|
99
|
+
else
|
100
|
+
controller.flash[:notice] ||= @notice if @notice
|
101
|
+
status = Responders::FlashResponder.flash_keys.first
|
105
102
|
end
|
106
|
-
end
|
107
103
|
|
108
|
-
|
104
|
+
return if controller.flash[status].present?
|
105
|
+
|
106
|
+
options = mount_i18n_options(status)
|
107
|
+
message = ::I18n.t options[:default].shift, options
|
108
|
+
controller.flash[status] = message unless message.blank?
|
109
|
+
end
|
109
110
|
|
110
|
-
def
|
111
|
+
def set_flash_message? #:nodoc:
|
111
112
|
!get? && @flash != false
|
112
113
|
end
|
113
114
|
|
@@ -15,23 +15,23 @@ module Responders
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_format
|
18
|
-
if do_http_cache?
|
19
|
-
timestamp = resources.flatten.map do |resource|
|
20
|
-
(resource.updated_at || Time.now).utc if resource.respond_to?(:updated_at)
|
21
|
-
end.compact.max
|
22
|
-
|
23
|
-
controller.response.last_modified = timestamp if timestamp
|
24
|
-
if request.fresh?(controller.response)
|
25
|
-
head :not_modified
|
26
|
-
return
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
18
|
+
return if do_http_cache? && do_http_cache!
|
30
19
|
super
|
31
20
|
end
|
32
21
|
|
33
22
|
protected
|
34
23
|
|
24
|
+
def do_http_cache!
|
25
|
+
timestamp = resources.flatten.map do |resource|
|
26
|
+
(resource.updated_at || Time.now).utc if resource.respond_to?(:updated_at)
|
27
|
+
end.compact.max
|
28
|
+
|
29
|
+
controller.response.last_modified = timestamp if timestamp
|
30
|
+
|
31
|
+
head :not_modified if fresh = request.fresh?(controller.response)
|
32
|
+
fresh
|
33
|
+
end
|
34
|
+
|
35
35
|
def do_http_cache?
|
36
36
|
get? && @http_cache != false && !new_record? && controller.response.last_modified.nil?
|
37
37
|
end
|
data/lib/responders/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-06 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|