show_for 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -5
- data/lib/show_for/helper.rb +3 -2
- data/lib/show_for/locale/en.yml +1 -1
- data/lib/show_for/version.rb +1 -1
- data/test/helper_test.rb +9 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -54,23 +54,23 @@ Will generate something like:
|
|
54
54
|
|
55
55
|
<div id="admin_1" class="show_for admin">
|
56
56
|
<p class="wrapper admin_name">
|
57
|
-
<
|
57
|
+
<strong class="label">Name</strong><br />
|
58
58
|
José Valim
|
59
59
|
</p>
|
60
60
|
<p class="wrapper admin_confirmed">
|
61
|
-
<
|
61
|
+
<strong class="label">Confirmed?</strong><br />
|
62
62
|
Yes
|
63
63
|
</p>
|
64
64
|
<p class="wrapper admin_created_at">
|
65
|
-
<
|
65
|
+
<strong class="label">Created at</strong><br />
|
66
66
|
13/12/2009 - 19h17
|
67
67
|
</p>
|
68
68
|
<p id="sign_in_timestamp" class="wrapper admin_last_sign_in_at">
|
69
|
-
<
|
69
|
+
<strong class="label">Last sign in at</strong><br />
|
70
70
|
Administrator did not access yet
|
71
71
|
</p>
|
72
72
|
<p class="wrapper admin_photo">
|
73
|
-
<
|
73
|
+
<strong class="label">Photo</strong><br />
|
74
74
|
<img src="path/to/photo" />
|
75
75
|
</p>
|
76
76
|
</div>
|
data/lib/show_for/helper.rb
CHANGED
@@ -14,10 +14,11 @@ module ShowFor
|
|
14
14
|
|
15
15
|
html_options[:id] ||= dom_id(object)
|
16
16
|
html_options[:class] = "show_for #{dom_class(object)} #{html_options[:class]}".strip
|
17
|
+
builder_class = html_options.delete(:builder) || ShowFor::Builder
|
17
18
|
|
18
|
-
concat content_tag(tag, capture(
|
19
|
+
concat content_tag(tag, capture(builder_class.new(object, self), &block), html_options)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
ActionView::Base.send :include, ShowFor::Helper
|
24
|
+
ActionView::Base.send :include, ShowFor::Helper
|
data/lib/show_for/locale/en.yml
CHANGED
data/lib/show_for/version.rb
CHANGED
data/test/helper_test.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
+
class CustomBuilder < ShowFor::Builder
|
4
|
+
end
|
5
|
+
|
3
6
|
class HelperTest < ActionView::TestCase
|
4
7
|
test "show for yields an instance of ShowFor::Builder" do
|
5
8
|
show_for(@user) do |f|
|
@@ -7,6 +10,12 @@ class HelperTest < ActionView::TestCase
|
|
7
10
|
end
|
8
11
|
end
|
9
12
|
|
13
|
+
test "show for yields an instance of builder class specified by builder option" do
|
14
|
+
show_for(@user, :builder => CustomBuilder) do |f|
|
15
|
+
assert f.instance_of?(CustomBuilder)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
10
19
|
test "show for should add default class to form" do
|
11
20
|
show_for(@user) do |f| end
|
12
21
|
assert_select "div.show_for"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: show_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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: 2010-01-
|
12
|
+
date: 2010-01-18 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|