table_for 0.0.2 → 0.0.3
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/lib/table_for/helper.rb +2 -2
- data/lib/table_for/table.rb +10 -2
- data/lib/table_for/version.rb +1 -1
- metadata +4 -4
data/lib/table_for/helper.rb
CHANGED
@@ -29,8 +29,8 @@ module TableFor
|
|
29
29
|
#
|
30
30
|
# (Call this method from your erb templates by wrapping each line in <%= %> or <% %>)
|
31
31
|
|
32
|
-
def table_for(model_class, records, &block)
|
33
|
-
Table.new(self, model_class, records, block).render
|
32
|
+
def table_for(model_class, records, html = {}, &block)
|
33
|
+
Table.new(self, model_class, records, html, block).render
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/lib/table_for/table.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module TableFor
|
2
|
-
class Table < Struct.new(:template, :model_class, :records, :block)
|
2
|
+
class Table < Struct.new(:template, :model_class, :records, :html, :block)
|
3
3
|
attr_accessor :columns, :rows
|
4
4
|
delegate :capture, :content_tag, :to => :template
|
5
5
|
|
@@ -12,13 +12,21 @@ module TableFor
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def render
|
15
|
-
content_tag(:table, :class =>
|
15
|
+
content_tag(:table, :class => css_class) do
|
16
16
|
caption + capture(TableBuilder.new(self), &block)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
protected
|
21
21
|
|
22
|
+
def css_class
|
23
|
+
[human_association_name.downcase, 'list', extra_css_class].compact
|
24
|
+
end
|
25
|
+
|
26
|
+
def extra_css_class
|
27
|
+
if html[:class].is_a?(String) then html[:class].split else html[:class] end
|
28
|
+
end
|
29
|
+
|
22
30
|
def caption
|
23
31
|
content_tag(:caption, human_association_name)
|
24
32
|
end
|
data/lib/table_for/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Nicklas Ramh\xC3\xB6j"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-11-02 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|