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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cefef031ead65141131e7f72f00e5566ff583af3f75aa206582c2995d6049ddb
4
- data.tar.gz: 152bd5da392923c16cb846e7a0baea169ac376e2934d36ad2edbfc1f0ed74bcd
3
+ metadata.gz: 005aad0fa1bb9ee0b93c116a8ff16ee6b9221393b7218ace6458a0a205edf851
4
+ data.tar.gz: 3184951a3460ebb9c4b3afc7174f2956789d7a1617b6b6bdf0a8c7567298ab71
5
5
  SHA512:
6
- metadata.gz: 4936d1d24877c51abd5b9a7d3e2e9328732444ff662cca0b02ee77bf241be82522148ccc617b933186fbe40f0b1b0eaaf47cdfa75a57587b09ffcf3a6f763df7
7
- data.tar.gz: 0f83b7762c858159b2ede8ec942210b7cca5a6b3b9a2d1da0cd4dff885df9007588b0e3c9a4641aa53b0c9af70d6178983fecf8d195b072b783ecff4b2408d5d
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
  {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YiffSpace
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yiffspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan_DMC