stackable_flash 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README.md +26 -1
- data/lib/stackable_flash/version.rb +1 -1
- data/stackable_flash.gemspec +1 -0
- metadata +18 -2
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
stackable_flash
|
2
2
|
===============
|
3
3
|
|
4
|
-
|
4
|
+
Allows flashes to stack intelligently, while preserving existing behavior of Rails' FlashHash.
|
5
|
+
|
6
|
+
Stackable Flash overrides the :[]= method of Rails' FlashHash with the result being that each flash key is an array.
|
7
|
+
It is designed following the "Principle of least surprise", so in most ways the flash works as it always has.
|
8
|
+
Only now you can push things onto the array with `:<<`, and generally interact with the flash as an array.
|
9
|
+
In order to be as compatible as possible with existing implementations of the FlashHash on websites, `:[]=` will still
|
10
|
+
replace the entire object at that key.
|
5
11
|
|
6
12
|
## Installation
|
7
13
|
|
@@ -17,6 +23,23 @@ Or install it yourself as:
|
|
17
23
|
|
18
24
|
$ gem install stackable_flash
|
19
25
|
|
26
|
+
## Config (Optional)
|
27
|
+
|
28
|
+
In an environment file, or application.rb
|
29
|
+
|
30
|
+
# Here are a few ideas (Don't do them all, pick one):
|
31
|
+
# You can use a lambda instead of a proc
|
32
|
+
StackableFlash::Config.configure do
|
33
|
+
# Leave it as an array
|
34
|
+
config[:stack_with_proc] = Proc.new {|arr| arr } )
|
35
|
+
# Make a set of statements separated by br tags
|
36
|
+
config[:stack_with_proc] = Proc.new {|arr| arr.join('<br/>') } ) # THIS IS DEFAULT IF LEFT UNCONFIGURED
|
37
|
+
# Make a set of p tags:
|
38
|
+
config[:stack_with_proc] = Proc.new {|arr| arr.map! {|x| "<p>#{x}</p>"}.join } } )
|
39
|
+
# Make an unordered list of tags:
|
40
|
+
config[:stack_with_proc] = Proc.new {|arr| '<ul>' + arr.map! {|x| "<li>#{x}</li>"}.join + '</ul> } } )
|
41
|
+
end
|
42
|
+
|
20
43
|
## Usage
|
21
44
|
|
22
45
|
When turned on all flashes can be interacted with as arrays.
|
@@ -59,6 +82,7 @@ There are block helpers which I am sure some enterprising individual will have a
|
|
59
82
|
flash[:notice] = 'original'
|
60
83
|
flash[:notice] << 'message'
|
61
84
|
flash[:notice] # => ['original','message']
|
85
|
+
# Uses the :stack_with_proc to transform
|
62
86
|
flash[:notice].stack # => '<p>original</p><p>message</p>'
|
63
87
|
end
|
64
88
|
|
@@ -68,6 +92,7 @@ And
|
|
68
92
|
flash[:notice] = 'original'
|
69
93
|
flash[:notice] << ' message'
|
70
94
|
flash[:notice] # => 'original message'
|
95
|
+
# Uses the :stack_with_proc to transform
|
71
96
|
flash[:notice].stack # => NoMethodError !!!
|
72
97
|
end
|
73
98
|
|
data/stackable_flash.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_development_dependency(%q<rspec-rails>, [">= 2.11.0"])
|
22
22
|
gem.add_development_dependency(%q<reek>, [">= 1.2.8"])
|
23
23
|
gem.add_development_dependency(%q<roodi>, [">= 2.1.0"])
|
24
|
+
gem.add_development_dependency(%q<rake>, [">= 0"])
|
24
25
|
|
25
26
|
end
|
26
27
|
|
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.2
|
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-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: 2.1.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rake
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
94
110
|
description: Allows flashes to stack intelligently, while preserving existing behavior
|
95
111
|
of the Rails FlashHash
|
96
112
|
email:
|