yiffspace 0.1.6 → 0.1.7
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.
- checksums.yaml +4 -4
- data/lib/yiffspace/utils/table_builder.rb +29 -0
- data/lib/yiffspace/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 005aad0fa1bb9ee0b93c116a8ff16ee6b9221393b7218ace6458a0a205edf851
|
|
4
|
+
data.tar.gz: 3184951a3460ebb9c4b3afc7174f2956789d7a1617b6b6bdf0a8c7567298ab71
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3aedc62b4a752a0124e8a41ac8aa013ea5a54cc7f95d5876afda928bcad70e9b13b0744a42cde382dfb2a7d4af3f7d906493971c28f0813d9f24de7ef70fb23
|
|
7
|
+
data.tar.gz: 0063344df91e5a741fe752be20b1f591b51df35bbc16746a7eb51d155c16b77c8d39824a7a8f0dc7c2f852444c48fe802b84f00ac9a7ab6e34af08c0489b46bc
|
|
@@ -79,6 +79,29 @@ module YiffSpace
|
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
# Represents a custom row in the table body.
|
|
83
|
+
class Row
|
|
84
|
+
attr_reader(:block, :row_attributes)
|
|
85
|
+
|
|
86
|
+
def initialize(row_attributes = {}, &block)
|
|
87
|
+
@row_attributes = row_attributes
|
|
88
|
+
@block = block
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def custom?
|
|
92
|
+
true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def value(index)
|
|
96
|
+
view = block.binding.receiver
|
|
97
|
+
if view.respond_to?(:capture)
|
|
98
|
+
view.capture { block.call(index, self) }
|
|
99
|
+
else
|
|
100
|
+
block.call(index, self)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
82
105
|
attr_reader(:columns, :table_attributes, :row_attributes, :items)
|
|
83
106
|
|
|
84
107
|
# Build a table for an array of objects, one object per row.
|
|
@@ -122,11 +145,17 @@ module YiffSpace
|
|
|
122
145
|
@columns << Column.new(*, **options, &)
|
|
123
146
|
end
|
|
124
147
|
|
|
148
|
+
def row(row_attributes = {}, &)
|
|
149
|
+
@items = @items.to_a unless @items.is_a?(Array)
|
|
150
|
+
@items << Row.new(row_attributes, &)
|
|
151
|
+
end
|
|
152
|
+
|
|
125
153
|
# Return the HTML attributes for each <tr> tag.
|
|
126
154
|
# @param item [ApplicationRecord] the item for this row
|
|
127
155
|
# @param _row [Integer] the row number (unused)
|
|
128
156
|
# @return [Hash] the <tr> attributes
|
|
129
157
|
def all_row_attributes(item, _row)
|
|
158
|
+
return item.row_attributes if item.is_a?(Row)
|
|
130
159
|
return {} unless item.is_a?(YiffSpace.config.application_record_class)
|
|
131
160
|
|
|
132
161
|
{
|
data/lib/yiffspace/version.rb
CHANGED