flash-message-conductor 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
@@ -4,13 +4,11 @@ A simple pattern for managing flash messages in your Ruby on Rails application.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
***This branch is considered an Alpha release.***
|
8
|
-
|
9
7
|
***This branch is only used for Rails 3. Still using Rails 2? Use [https://github.com/planetargon/flash-message-conductor/tree/rails2](https://github.com/planetargon/flash-message-conductor/tree/rails2) instead.***
|
10
8
|
|
11
9
|
Add this line to your application's Gemfile:
|
12
10
|
|
13
|
-
gem "flash-message-conductor", "~> 2.0"
|
11
|
+
gem "flash-message-conductor", "~> 2.0.1"
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
@@ -40,6 +38,7 @@ Or install it yourself as:
|
|
40
38
|
add_message(message)
|
41
39
|
add_notice(message)
|
42
40
|
add_error(message)
|
41
|
+
add_alert(message)
|
43
42
|
```
|
44
43
|
|
45
44
|
### View helpers
|
@@ -72,7 +71,7 @@ Or install it yourself as:
|
|
72
71
|
<% end -%>
|
73
72
|
```
|
74
73
|
|
75
|
-
Copyright (c) 2008-
|
74
|
+
Copyright (c) 2008-2013 Planet Argon, released under the MIT license
|
76
75
|
|
77
76
|
### Contributing
|
78
77
|
|
@@ -1,25 +1,20 @@
|
|
1
1
|
module FlashMessageConductor
|
2
|
-
FLASH_MESSAGE_TYPES = [ :error, :notice, :message ]
|
2
|
+
FLASH_MESSAGE_TYPES = [ :alert, :error, :notice, :message ]
|
3
3
|
|
4
4
|
module ControllerHelpers
|
5
|
-
|
6
|
-
flash[:error] = msg
|
5
|
+
module ClassMethods
|
7
6
|
end
|
8
|
-
|
9
|
-
|
10
|
-
flash[:notice] = msg
|
7
|
+
FLASH_MESSAGE_TYPES.each do |message_type|
|
8
|
+
define_method("add_#{message_type.to_s}") { |message| flash[message_type] = message}
|
11
9
|
end
|
12
10
|
|
13
|
-
def
|
14
|
-
flash[
|
11
|
+
def flash_message_set?
|
12
|
+
FLASH_MESSAGE_TYPES.any? { |key| flash[key].present? }
|
15
13
|
end
|
16
14
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
flash_set = true unless flash[key].blank?
|
21
|
-
end
|
22
|
-
return flash_set
|
15
|
+
def self.included(base)
|
16
|
+
base.extend ClassMethods
|
17
|
+
base.helper_method :flash_message_set?
|
23
18
|
end
|
24
19
|
end
|
25
20
|
end
|
@@ -1,28 +1,19 @@
|
|
1
1
|
module FlashMessageConductor
|
2
2
|
module ViewHelpers
|
3
3
|
def render_flash_message(css_class, message = "")
|
4
|
-
return "" if message.
|
4
|
+
return "" if message.blank?
|
5
5
|
content_tag("p", message.html_safe, :class => "#{css_class}")
|
6
6
|
end
|
7
7
|
|
8
8
|
def render_flash_messages(div_id = "flash_messages", div_class = "")
|
9
|
+
return unless flash_message_set?
|
10
|
+
|
9
11
|
div_content = ''
|
10
12
|
FLASH_MESSAGE_TYPES.each do |key|
|
11
13
|
div_content << render_flash_message(key.to_s, flash[key]) unless flash[key].blank?
|
12
14
|
end
|
13
|
-
if div_content.blank?
|
14
|
-
return ""
|
15
|
-
else
|
16
|
-
return content_tag('div', div_content.html_safe, :id => div_id, :class => div_class)
|
17
|
-
end
|
18
|
-
end
|
19
15
|
|
20
|
-
|
21
|
-
flash_set = false
|
22
|
-
FLASH_MESSAGE_TYPES.each do |key|
|
23
|
-
flash_set = true unless flash[key].blank?
|
24
|
-
end
|
25
|
-
return flash_set
|
16
|
+
content_tag('div', div_content.html_safe, :id => div_id, :class => div_class)
|
26
17
|
end
|
27
18
|
end
|
28
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flash-message-conductor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: A simple pattern for managing flash messages in your Ruby on Rails application
|
16
16
|
email:
|