csvbuilder-dynamic-columns-importer 0.1.0 → 0.1.2
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/.rubocop.yml +1 -1
- data/.tool-versions +1 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +83 -57
- data/README.md +70 -7
- data/gemfiles/{Gemfile.5.2._gemfile → Gemfile.8.0._gemfile} +1 -1
- data/lib/csvbuilder/dynamic/columns/importer/internal/import/dynamic_column_attribute.rb +2 -2
- data/lib/csvbuilder/dynamic/columns/importer/version.rb +1 -1
- metadata +17 -27
- data/gemfiles/Gemfile.6.1._gemfile +0 -19
- data/lib/csvbuilder/dynamic/columns/importer/internal/dynamic_column_attribute_base.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bef7a73cce7d047dda75a72642c5478aa9076cd7d8dcb984b409aaaaaecf6f3f
|
4
|
+
data.tar.gz: 6880145dd7656e03409f9b5a811572a0034c9a81c780e790e18eb29abb2b365f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95fc3ceca8a0f9fb982cd123b1d4a438d9b758f89233149128118351058b5c2adef56c4b5a3ed24c891c77983e13f910cf009792aab78e1813ce74151e974c01
|
7
|
+
data.tar.gz: 5e4e302298a9ee4df2dfe6e3e7eb9392cac5baf2529db5fed9c167b30d53122f27e06ccb2e85774a2c3391b63e2907095153e72bb9bac65335de9411a2d23cc9
|
data/.rubocop.yml
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.4.2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.2] - 2024-02-27
|
4
|
+
|
5
|
+
- Update Ruby 3.4 and Relax Rails Constraint
|
6
|
+
|
7
|
+
## [0.1.1] - 2022-12-30
|
8
|
+
|
9
|
+
Do not apply double formatting to the cells. The method `unformatted_value` should get the raw values from `source_cells`, not the value already formatted by row_model.format_cell.
|
10
|
+
|
3
11
|
## [0.1.0] - 2022-12-21
|
4
12
|
|
5
13
|
- Initial release
|
data/Gemfile.lock
CHANGED
@@ -1,84 +1,110 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
csvbuilder-dynamic-columns-importer (0.1.
|
5
|
-
activesupport (>= 5.2
|
6
|
-
csvbuilder-core
|
7
|
-
csvbuilder-dynamic-columns-core
|
8
|
-
csvbuilder-importer
|
4
|
+
csvbuilder-dynamic-columns-importer (0.1.2)
|
5
|
+
activesupport (>= 5.2)
|
6
|
+
csvbuilder-core (~> 0.1)
|
7
|
+
csvbuilder-dynamic-columns-core (~> 0.1)
|
8
|
+
csvbuilder-importer (~> 0.1)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activemodel (7.
|
14
|
-
activesupport (= 7.
|
15
|
-
activesupport (7.
|
16
|
-
|
13
|
+
activemodel (7.2.2.1)
|
14
|
+
activesupport (= 7.2.2.1)
|
15
|
+
activesupport (7.2.2.1)
|
16
|
+
base64
|
17
|
+
benchmark (>= 0.3)
|
18
|
+
bigdecimal
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
20
|
+
connection_pool (>= 2.2.5)
|
21
|
+
drb
|
17
22
|
i18n (>= 1.6, < 2)
|
23
|
+
logger (>= 1.4.2)
|
18
24
|
minitest (>= 5.1)
|
19
|
-
|
25
|
+
securerandom (>= 0.3)
|
26
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
20
27
|
ast (2.4.2)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
base64 (0.2.0)
|
29
|
+
benchmark (0.4.0)
|
30
|
+
bigdecimal (3.1.9)
|
31
|
+
concurrent-ruby (1.3.5)
|
32
|
+
connection_pool (2.5.0)
|
33
|
+
csv (3.3.2)
|
34
|
+
csvbuilder-core (0.1.4)
|
35
|
+
activesupport (>= 5.2)
|
36
|
+
csv
|
37
|
+
csvbuilder-dynamic-columns-core (0.1.1)
|
25
38
|
activesupport (>= 5.2, < 8)
|
26
39
|
csvbuilder-core
|
27
|
-
csvbuilder-importer (0.1.
|
28
|
-
activemodel (>= 5.2
|
29
|
-
activesupport (>= 5.2
|
40
|
+
csvbuilder-importer (0.1.5.1)
|
41
|
+
activemodel (>= 5.2)
|
42
|
+
activesupport (>= 5.2)
|
30
43
|
csvbuilder-core
|
31
|
-
diff-lcs (1.
|
32
|
-
|
44
|
+
diff-lcs (1.6.0)
|
45
|
+
drb (2.2.1)
|
46
|
+
i18n (1.14.7)
|
33
47
|
concurrent-ruby (~> 1.0)
|
34
|
-
json (2.
|
35
|
-
|
36
|
-
|
37
|
-
|
48
|
+
json (2.10.1)
|
49
|
+
language_server-protocol (3.17.0.4)
|
50
|
+
lint_roller (1.1.0)
|
51
|
+
logger (1.6.6)
|
52
|
+
minitest (5.25.4)
|
53
|
+
parallel (1.26.3)
|
54
|
+
parser (3.3.7.1)
|
38
55
|
ast (~> 2.4.1)
|
56
|
+
racc
|
57
|
+
racc (1.8.1)
|
39
58
|
rainbow (3.1.1)
|
40
|
-
rake (13.
|
41
|
-
regexp_parser (2.
|
42
|
-
|
43
|
-
|
44
|
-
rspec-
|
45
|
-
rspec-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
rspec-expectations (3.12.1)
|
59
|
+
rake (13.2.1)
|
60
|
+
regexp_parser (2.10.0)
|
61
|
+
rspec (3.13.0)
|
62
|
+
rspec-core (~> 3.13.0)
|
63
|
+
rspec-expectations (~> 3.13.0)
|
64
|
+
rspec-mocks (~> 3.13.0)
|
65
|
+
rspec-core (3.13.3)
|
66
|
+
rspec-support (~> 3.13.0)
|
67
|
+
rspec-expectations (3.13.3)
|
50
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-mocks (3.
|
69
|
+
rspec-support (~> 3.13.0)
|
70
|
+
rspec-mocks (3.13.2)
|
53
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
-
rspec-support (~> 3.
|
55
|
-
rspec-support (3.
|
56
|
-
rubocop (1.
|
72
|
+
rspec-support (~> 3.13.0)
|
73
|
+
rspec-support (3.13.2)
|
74
|
+
rubocop (1.73.0)
|
57
75
|
json (~> 2.3)
|
76
|
+
language_server-protocol (~> 3.17.0.2)
|
77
|
+
lint_roller (~> 1.1.0)
|
58
78
|
parallel (~> 1.10)
|
59
|
-
parser (>= 3.
|
79
|
+
parser (>= 3.3.0.2)
|
60
80
|
rainbow (>= 2.2.2, < 4.0)
|
61
|
-
regexp_parser (>=
|
62
|
-
|
63
|
-
rubocop-ast (>= 1.23.0, < 2.0)
|
81
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
82
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
64
83
|
ruby-progressbar (~> 1.7)
|
65
|
-
unicode-display_width (>=
|
66
|
-
rubocop-ast (1.
|
67
|
-
parser (>= 3.
|
68
|
-
rubocop-performance (1.
|
69
|
-
|
70
|
-
rubocop
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
rubocop (
|
75
|
-
|
76
|
-
|
84
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
85
|
+
rubocop-ast (1.38.1)
|
86
|
+
parser (>= 3.3.1.0)
|
87
|
+
rubocop-performance (1.24.0)
|
88
|
+
lint_roller (~> 1.1)
|
89
|
+
rubocop (>= 1.72.1, < 2.0)
|
90
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
91
|
+
rubocop-rake (0.7.1)
|
92
|
+
lint_roller (~> 1.1)
|
93
|
+
rubocop (>= 1.72.1)
|
94
|
+
rubocop-rspec (3.5.0)
|
95
|
+
lint_roller (~> 1.1)
|
96
|
+
rubocop (~> 1.72, >= 1.72.1)
|
97
|
+
ruby-progressbar (1.13.0)
|
98
|
+
securerandom (0.4.1)
|
99
|
+
tzinfo (2.0.6)
|
77
100
|
concurrent-ruby (~> 1.0)
|
78
|
-
unicode-display_width (
|
101
|
+
unicode-display_width (3.1.4)
|
102
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
103
|
+
unicode-emoji (4.0.4)
|
79
104
|
|
80
105
|
PLATFORMS
|
81
|
-
arm64-darwin-
|
106
|
+
arm64-darwin-24
|
107
|
+
ruby
|
82
108
|
|
83
109
|
DEPENDENCIES
|
84
110
|
csvbuilder-dynamic-columns-importer!
|
@@ -90,4 +116,4 @@ DEPENDENCIES
|
|
90
116
|
rubocop-rspec
|
91
117
|
|
92
118
|
BUNDLED WITH
|
93
|
-
2.
|
119
|
+
2.6.2
|
data/README.md
CHANGED
@@ -1,22 +1,85 @@
|
|
1
|
-
# Csvbuilder::Dynamic::Columns
|
1
|
+
# Csvbuilder::Dynamic::Columns::Importer
|
2
2
|
|
3
|
-
|
3
|
+
[Csvbuilder::Dynamic::Columns::Importer](https://github.com/joel/csvbuilder-dynamic-columns-importer) is part of the [csvbuilder-collection](https://github.com/joel/csvbuilder)
|
4
4
|
|
5
|
-
|
5
|
+
The Dynamic Columns Importer contains the implementation for importing CSV data with a variable group, for instance, an object with categories.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Install the gem and add to the application's Gemfile by executing:
|
10
10
|
|
11
|
-
$ bundle add csvbuilder-dynamic-columns
|
11
|
+
$ bundle add csvbuilder-dynamic-columns-importer
|
12
12
|
|
13
13
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
14
|
|
15
|
-
$ gem install csvbuilder-dynamic-columns
|
15
|
+
$ gem install csvbuilder-dynamic-columns-importer
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
-
|
19
|
+
Let's consider a Developer with languages skill.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
class UserCsvImportModel
|
23
|
+
include Csvbuilder::Model
|
24
|
+
include Csvbuilder::Import
|
25
|
+
|
26
|
+
column :name, header: "Developer"
|
27
|
+
|
28
|
+
dynamic_column :skills
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
The Row can iterate over the Dynamic Columns. Here are `skills`, and get access to the cell values.
|
33
|
+
|
34
|
+
For each entry of the Dynamic Columns, here `skills`, a method called by the singular version name of the declared Dynamic Columns will be called here `skill`.
|
35
|
+
|
36
|
+
This method provides the header value and the cell value; however, it returns only the cell value by default; if that is all that is needed, there is no need for overriding.
|
37
|
+
|
38
|
+
However, it is safe to override this method to put in place any logic needed.
|
39
|
+
|
40
|
+
For instance, returning the header and cell values to figure out what the importer has to do with them.
|
41
|
+
|
42
|
+
Check out the following example:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
class UserCsvImportModel
|
46
|
+
include Csvbuilder::Model
|
47
|
+
include Csvbuilder::Import
|
48
|
+
|
49
|
+
column :name, header: "Developer"
|
50
|
+
|
51
|
+
dynamic_column :skills
|
52
|
+
|
53
|
+
def user
|
54
|
+
User.where(name: name).take
|
55
|
+
end
|
56
|
+
|
57
|
+
def skill(value, header_value)
|
58
|
+
{ skill: header_value, has: value }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
[
|
65
|
+
["Developer", "Ruby", "Python", "Javascript"],
|
66
|
+
["Bob" , "1", "0", "1"],
|
67
|
+
]
|
68
|
+
```
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
options = {}
|
72
|
+
|
73
|
+
Csvbuilder::Import::File.new(file.path, UserCsvImportModel, options).each do |row_model|
|
74
|
+
row_model.skills.each do |skill_data|
|
75
|
+
skill = Skill.find_or_create_by(name: skill_data[:skill])
|
76
|
+
row_model.user.skills << skill if skill_data[:has] == "1"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
User.where(name: "Bob").take.skills.pluck(:name)
|
81
|
+
# => ["Ruby", "Javascript"]
|
82
|
+
```
|
20
83
|
|
21
84
|
## Development
|
22
85
|
|
@@ -26,7 +89,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
26
89
|
|
27
90
|
## Contributing
|
28
91
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joel/csvbuilder-dynamic-columns. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/csvbuilder-dynamic-columns/blob/main/CODE_OF_CONDUCT.md).
|
30
93
|
|
31
94
|
## License
|
32
95
|
|
@@ -15,8 +15,8 @@ module Csvbuilder
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def unformatted_value
|
18
|
-
|
19
|
-
call_process_cell(
|
18
|
+
source_cells.zip(formatted_headers).map do |source_cell, formatted_header|
|
19
|
+
call_process_cell(source_cell, formatted_header)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csvbuilder-dynamic-columns-importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Azemar
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-27 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -17,9 +16,6 @@ dependencies:
|
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '5.2'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '8'
|
23
19
|
type: :runtime
|
24
20
|
prerelease: false
|
25
21
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,51 +23,48 @@ dependencies:
|
|
27
23
|
- - ">="
|
28
24
|
- !ruby/object:Gem::Version
|
29
25
|
version: '5.2'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '8'
|
33
26
|
- !ruby/object:Gem::Dependency
|
34
27
|
name: csvbuilder-core
|
35
28
|
requirement: !ruby/object:Gem::Requirement
|
36
29
|
requirements:
|
37
|
-
- - "
|
30
|
+
- - "~>"
|
38
31
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
32
|
+
version: '0.1'
|
40
33
|
type: :runtime
|
41
34
|
prerelease: false
|
42
35
|
version_requirements: !ruby/object:Gem::Requirement
|
43
36
|
requirements:
|
44
|
-
- - "
|
37
|
+
- - "~>"
|
45
38
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
39
|
+
version: '0.1'
|
47
40
|
- !ruby/object:Gem::Dependency
|
48
41
|
name: csvbuilder-dynamic-columns-core
|
49
42
|
requirement: !ruby/object:Gem::Requirement
|
50
43
|
requirements:
|
51
|
-
- - "
|
44
|
+
- - "~>"
|
52
45
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
46
|
+
version: '0.1'
|
54
47
|
type: :runtime
|
55
48
|
prerelease: false
|
56
49
|
version_requirements: !ruby/object:Gem::Requirement
|
57
50
|
requirements:
|
58
|
-
- - "
|
51
|
+
- - "~>"
|
59
52
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
53
|
+
version: '0.1'
|
61
54
|
- !ruby/object:Gem::Dependency
|
62
55
|
name: csvbuilder-importer
|
63
56
|
requirement: !ruby/object:Gem::Requirement
|
64
57
|
requirements:
|
65
|
-
- - "
|
58
|
+
- - "~>"
|
66
59
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
60
|
+
version: '0.1'
|
68
61
|
type: :runtime
|
69
62
|
prerelease: false
|
70
63
|
version_requirements: !ruby/object:Gem::Requirement
|
71
64
|
requirements:
|
72
|
-
- - "
|
65
|
+
- - "~>"
|
73
66
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
67
|
+
version: '0.1'
|
75
68
|
description: Help handle CSVs in a more efficient way
|
76
69
|
email:
|
77
70
|
- joel.azemar@gmail.com
|
@@ -83,6 +76,7 @@ files:
|
|
83
76
|
- ".rspec"
|
84
77
|
- ".rubocop.yml"
|
85
78
|
- ".rubocop_todo.yml"
|
79
|
+
- ".tool-versions"
|
86
80
|
- CHANGELOG.md
|
87
81
|
- CODE_OF_CONDUCT.md
|
88
82
|
- Gemfile
|
@@ -90,16 +84,14 @@ files:
|
|
90
84
|
- LICENSE.txt
|
91
85
|
- README.md
|
92
86
|
- Rakefile
|
93
|
-
- gemfiles/Gemfile.5.2._gemfile
|
94
|
-
- gemfiles/Gemfile.6.1._gemfile
|
95
87
|
- gemfiles/Gemfile.7.0._gemfile
|
88
|
+
- gemfiles/Gemfile.8.0._gemfile
|
96
89
|
- lib/.DS_Store
|
97
90
|
- lib/csvbuilder/.DS_Store
|
98
91
|
- lib/csvbuilder/dynamic/.DS_Store
|
99
92
|
- lib/csvbuilder/dynamic/columns/.DS_Store
|
100
93
|
- lib/csvbuilder/dynamic/columns/importer.rb
|
101
94
|
- lib/csvbuilder/dynamic/columns/importer/concerns/import/dynamic_columns.rb
|
102
|
-
- lib/csvbuilder/dynamic/columns/importer/internal/dynamic_column_attribute_base.rb
|
103
95
|
- lib/csvbuilder/dynamic/columns/importer/internal/import/dynamic_column_attribute.rb
|
104
96
|
- lib/csvbuilder/dynamic/columns/importer/public/import.rb
|
105
97
|
- lib/csvbuilder/dynamic/columns/importer/version.rb
|
@@ -111,7 +103,6 @@ metadata:
|
|
111
103
|
source_code_uri: https://github.com/joel/csvbuilder-dynamic-columns-importer
|
112
104
|
changelog_uri: https://github.com/joel/csvbuilder-dynamic-columns-importer/blob/main/CHANGELOG.md
|
113
105
|
rubygems_mfa_required: 'true'
|
114
|
-
post_install_message:
|
115
106
|
rdoc_options: []
|
116
107
|
require_paths:
|
117
108
|
- lib
|
@@ -126,8 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
117
|
- !ruby/object:Gem::Version
|
127
118
|
version: '0'
|
128
119
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
130
|
-
signing_key:
|
120
|
+
rubygems_version: 3.6.2
|
131
121
|
specification_version: 4
|
132
122
|
summary: Csvbuilder Dynamic Columns contain the components to handle CSV dynamic columns
|
133
123
|
test_files: []
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Runtime dependencies
|
6
|
-
gem "activesupport", "~> 6.1"
|
7
|
-
|
8
|
-
# Libraries dependencies
|
9
|
-
gem "csvbuilder-core"
|
10
|
-
gem "csvbuilder-dynamic-columns-core"
|
11
|
-
gem "csvbuilder-importer"
|
12
|
-
|
13
|
-
# Development dependencies
|
14
|
-
gem "rake"
|
15
|
-
gem "rspec"
|
16
|
-
gem "rubocop"
|
17
|
-
gem "rubocop-performance"
|
18
|
-
gem "rubocop-rake"
|
19
|
-
gem "rubocop-rspec"
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "csvbuilder/core/internal/attribute_base"
|
4
|
-
require "csvbuilder/dynamic/columns/core/internal/concerns/dynamic_column_shared"
|
5
|
-
|
6
|
-
module Csvbuilder
|
7
|
-
class DynamicColumnAttributeBase < AttributeBase
|
8
|
-
include DynamicColumnShared
|
9
|
-
|
10
|
-
def value
|
11
|
-
@value ||= row_model_class.format_dynamic_column_cells(unformatted_value, column_name, row_model.context)
|
12
|
-
end
|
13
|
-
|
14
|
-
def formatted_cells
|
15
|
-
source_cells.map do |cell|
|
16
|
-
row_model_class.format_cell(cell, column_name, row_model.context)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
def process_cell_method_name
|
23
|
-
self.class.process_cell_method_name(column_name)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Calls the process_cell to return the value of a Attribute given the args
|
27
|
-
def call_process_cell(*args)
|
28
|
-
row_model.public_send(process_cell_method_name, *args)
|
29
|
-
end
|
30
|
-
|
31
|
-
class << self
|
32
|
-
def process_cell_method_name(column_name)
|
33
|
-
column_name.to_s.singularize.to_sym
|
34
|
-
end
|
35
|
-
|
36
|
-
# define a method to process each cell of the attribute method
|
37
|
-
# process_cell = one cell
|
38
|
-
# attribute_method = many cells = [process_cell(), process_cell()...]
|
39
|
-
def define_process_cell(row_model_class, column_name, &block)
|
40
|
-
row_model_class.define_proxy_method(process_cell_method_name(column_name), &block)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|