rack-app-front_end 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/app/front_end/helpers/table.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79aa6e0540c91496fb40688c70656e16f36c40eb
|
4
|
+
data.tar.gz: 7dce84eb5f012007d72db48dcc7d236ad1610969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 184325dd6400fd8d4e770dea2fedd1bb21a713c8a1d2a1ea54649b619216039514d13033e5e5414e071cfa440774383b7e34f1765944aa3d623d78a97f2d1942
|
7
|
+
data.tar.gz: 1955e1036f1d114a21871122d5887f3ec3f748e36ca85b0eb76d39dc214ced0d387be3acfdd6023c505f5e335c3a4cebfd7e5730a5b2cedb9e830ea3ceaf76c5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.22.0
|
@@ -2,7 +2,7 @@ module Rack::App::FrontEnd::Helpers::Table
|
|
2
2
|
module Builder
|
3
3
|
extend(self)
|
4
4
|
|
5
|
-
def from_array_of_hash(array_of_hash)
|
5
|
+
def from_array_of_hash(array_of_hash, attributes)
|
6
6
|
headers = array_of_hash.each_with_object([]) do |hash, trs|
|
7
7
|
trs.push(*hash.keys)
|
8
8
|
trs.uniq!
|
@@ -11,7 +11,7 @@ module Rack::App::FrontEnd::Helpers::Table
|
|
11
11
|
o = Object.new
|
12
12
|
o.extend(Rack::App::FrontEnd::Helpers::HtmlDsl)
|
13
13
|
|
14
|
-
table_html = o.__send__ :table_tag do
|
14
|
+
table_html = o.__send__ :table_tag, attributes do
|
15
15
|
tr_tag do
|
16
16
|
headers.each do |header|
|
17
17
|
td_tag String(header)
|
@@ -30,11 +30,11 @@ module Rack::App::FrontEnd::Helpers::Table
|
|
30
30
|
table_html
|
31
31
|
end
|
32
32
|
|
33
|
-
def from_hash(hash)
|
33
|
+
def from_hash(hash, attributes)
|
34
34
|
o = Object.new
|
35
35
|
o.extend(Rack::App::FrontEnd::Helpers::HtmlDsl)
|
36
36
|
|
37
|
-
table_html = o.__send__ :table_tag do
|
37
|
+
table_html = o.__send__ :table_tag, attributes do
|
38
38
|
hash.each do |key, value|
|
39
39
|
tr_tag do
|
40
40
|
td_tag String(key)
|
@@ -47,11 +47,11 @@ module Rack::App::FrontEnd::Helpers::Table
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def table_by(object)
|
50
|
+
def table_by(object, attributes={})
|
51
51
|
if object.is_a?(Array) && object.all? { |e| e.is_a?(Hash) }
|
52
|
-
Builder.from_array_of_hash(object)
|
52
|
+
Builder.from_array_of_hash(object, attributes)
|
53
53
|
elsif object.is_a?(Hash)
|
54
|
-
Builder.from_hash(object)
|
54
|
+
Builder.from_hash(object, attributes)
|
55
55
|
else
|
56
56
|
raise("don't know how to build table from this: #{object}")
|
57
57
|
end
|