stackable_flash 0.0.3 → 0.0.4
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
@@ -31,13 +31,13 @@ In an environment file, or application.rb
|
|
31
31
|
# You can use a lambda instead of a proc
|
32
32
|
StackableFlash::Config.configure do
|
33
33
|
# Leave it as an array
|
34
|
-
config[:stack_with_proc] = Proc.new {|arr| arr }
|
34
|
+
config[:stack_with_proc] = Proc.new {|arr| arr }
|
35
35
|
# Make a set of statements separated by br tags
|
36
|
-
config[:stack_with_proc] = Proc.new {|arr| arr.join('<br/>') }
|
36
|
+
config[:stack_with_proc] = Proc.new {|arr| arr.join('<br/>') } # THIS IS DEFAULT IF LEFT UNCONFIGURED
|
37
37
|
# Make a set of p tags:
|
38
|
-
config[:stack_with_proc] = Proc.new {|arr| arr.map! {|x| "<p>#{x}</p>"}.join }
|
38
|
+
config[:stack_with_proc] = Proc.new {|arr| arr.map! {|x| "<p>#{x}</p>"}.join }
|
39
39
|
# Make an unordered list of tags:
|
40
|
-
config[:stack_with_proc] = Proc.new {|arr| '<ul>' + arr.map! {|x| "<li>#{x}</li>"}.join + '</ul> }
|
40
|
+
config[:stack_with_proc] = Proc.new {|arr| '<ul>' + arr.map! {|x| "<li>#{x}</li>"}.join + '</ul>' }
|
41
41
|
end
|
42
42
|
|
43
43
|
## Usage
|
@@ -96,10 +96,21 @@ And
|
|
96
96
|
flash[:notice].stack # => NoMethodError !!!
|
97
97
|
end
|
98
98
|
|
99
|
+
## Sightings
|
100
|
+
|
101
|
+
This gem is used by the cacheable_flash gem to provide stacking flashes. You can check it out for a working example.
|
102
|
+
|
99
103
|
## Contributing
|
100
104
|
|
101
105
|
1. Fork it
|
102
106
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
103
107
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
104
108
|
4. Push to the branch (`git push origin my-new-feature`)
|
105
|
-
5.
|
109
|
+
5. Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
110
|
+
6. Create new Pull Request
|
111
|
+
|
112
|
+
== Copyright
|
113
|
+
|
114
|
+
Licensed under the MIT License.
|
115
|
+
|
116
|
+
- Copyright (c) 2012 Peter H. Boling (http://peterboling.com). See LICENSE for further details.
|
@@ -5,9 +5,26 @@ module StackableFlash
|
|
5
5
|
def self.included(base)
|
6
6
|
base.class_eval do
|
7
7
|
alias_method_chain :[]=, :stacking
|
8
|
+
alias_method_chain :[], :stacking
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
12
|
+
define_method "[]_with_stacking" do |key|
|
13
|
+
if StackableFlash.stacking
|
14
|
+
#Do it in a non-stacking block so we get normal behavior from flash[:notice] calls
|
15
|
+
StackableFlash.not_stacked do
|
16
|
+
actual = send("[]_without_stacking", key)
|
17
|
+
if actual.nil?
|
18
|
+
send("[]_with_stacking=", key, StackableFlash::FlashStack.new)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
# All StackableFlash functionality is completely bypassed
|
23
|
+
send("[]_without_stacking", key)
|
24
|
+
end
|
25
|
+
return send("[]_without_stacking", key)
|
26
|
+
end
|
27
|
+
|
11
28
|
define_method "[]_with_stacking=" do |key, value|
|
12
29
|
if StackableFlash.stacking
|
13
30
|
# Do it in a non-stacking block so we get normal behavior from flash[:notice] calls
|
@@ -4,18 +4,27 @@ describe DummyController do
|
|
4
4
|
|
5
5
|
render_views
|
6
6
|
|
7
|
+
it "should handle multiple keys" do
|
8
|
+
get :multiple_keys
|
9
|
+
controller.flash[:notice].should == ['This is a Notice']
|
10
|
+
controller.flash[:errors].should == ['This is an Error']
|
11
|
+
end
|
12
|
+
|
7
13
|
it "should override" do
|
8
14
|
get :override
|
15
|
+
controller.flash[:notice].should_not == ['original']
|
9
16
|
controller.flash[:notice].should == ['message']
|
10
17
|
end
|
11
18
|
|
12
|
-
it "should
|
19
|
+
it "should stack" do
|
13
20
|
get :stack
|
14
21
|
controller.flash[:notice].should == ['original','message','another']
|
22
|
+
controller.flash[:notice].stack.should == 'original<br/>message<br/>another'
|
15
23
|
end
|
16
24
|
|
17
|
-
it "should
|
18
|
-
get :
|
25
|
+
it "should cold boot" do
|
26
|
+
get :cold_boot
|
27
|
+
controller.flash[:notice].should == ['original','message','another']
|
19
28
|
controller.flash[:notice].stack.should == 'original<br/>message<br/>another'
|
20
29
|
end
|
21
30
|
|
@@ -1,14 +1,29 @@
|
|
1
1
|
class DummyController < ApplicationController
|
2
|
-
|
2
|
+
|
3
|
+
def multiple_keys
|
4
|
+
flash[:notice] = 'This is a Notice'
|
5
|
+
flash[:errors] = 'This is an Error'
|
6
|
+
render :text => 'Foo'
|
7
|
+
end
|
8
|
+
|
3
9
|
def override
|
4
10
|
flash[:notice] = 'original'
|
5
11
|
flash[:notice] = 'message'
|
12
|
+
render :text => 'Foo'
|
6
13
|
end
|
7
14
|
|
8
15
|
def stack
|
9
16
|
flash[:notice] = 'original'
|
10
17
|
flash[:notice] << 'message'
|
11
18
|
flash[:notice] << 'another'
|
19
|
+
render :text => 'Foo'
|
20
|
+
end
|
21
|
+
|
22
|
+
def cold_boot
|
23
|
+
flash[:notice] << 'original'
|
24
|
+
flash[:notice] << 'message'
|
25
|
+
flash[:notice] << 'another'
|
26
|
+
render :text => 'Foo'
|
12
27
|
end
|
13
28
|
|
14
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackable_flash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|