sinatra-frank 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sinatra/flash_message.rb +28 -0
- data/lib/sinatra/frank.rb +2 -2
- data/lib/sinatra/frank/version.rb +1 -1
- metadata +3 -2
@@ -0,0 +1,28 @@
|
|
1
|
+
# Simple flash messaging in Sinatra
|
2
|
+
#
|
3
|
+
# require 'sinatra/flash_message'
|
4
|
+
#
|
5
|
+
# configure { enable :sessions }
|
6
|
+
# helpers { def flash; @flash ||= FlashMessage.new(session); end }
|
7
|
+
#
|
8
|
+
# get '/' do
|
9
|
+
# flash.message = 'hello world'
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# <%= flash.message %>
|
13
|
+
#
|
14
|
+
class FlashMessage
|
15
|
+
def initialize(session)
|
16
|
+
@session ||= session
|
17
|
+
end
|
18
|
+
|
19
|
+
def message=(message)
|
20
|
+
@session[:flash] = message
|
21
|
+
end
|
22
|
+
|
23
|
+
def message
|
24
|
+
message = @session[:flash]
|
25
|
+
@session[:flash] = nil
|
26
|
+
message
|
27
|
+
end
|
28
|
+
end
|
data/lib/sinatra/frank.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-frank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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: 2013-
|
12
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- LICENSE.txt
|
56
56
|
- README.md
|
57
57
|
- Rakefile
|
58
|
+
- lib/sinatra/flash_message.rb
|
58
59
|
- lib/sinatra/frank.rb
|
59
60
|
- lib/sinatra/frank/version.rb
|
60
61
|
- sinatra-frank.gemspec
|