active_record_to_hash 0.6.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/lib/active_record_to_hash/active_record.rb +2 -0
- data/lib/active_record_to_hash/utilities.rb +9 -3
- data/lib/active_record_to_hash/version.rb +3 -1
- data/lib/active_record_to_hash.rb +3 -1
- data/lib/tasks/active_record_to_hash_tasks.rake +1 -0
- metadata +36 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d58db5d3bc83a1c3d5aeacc76b93c4a74170cd56f4ccce73a7c2fbda1c231bad
|
4
|
+
data.tar.gz: a386699d79c74de0ea5a1f6446544ac90a61c56b355abff1bb17b40c1f1a1f52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9131d35e459532105d66f8144d73c152a6f0a66f1f1e366ddfdbacd34b6ee223c1b6457ce03682be00323db915ed09eadabda846ad5056c7aaac61b0e8e1dfca
|
7
|
+
data.tar.gz: 5ca180e0781e2bad5bfc98a697394ee44d6c9ab87a8222e81bc25041810af1df57cd291962a9f3529edee7ae3c8c63e92e17ca6ff27c2654f7699d5a5defc06d
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecordToHash
|
2
4
|
module_function
|
3
5
|
|
@@ -18,7 +20,11 @@ module ActiveRecordToHash
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def retrieve_child_attribute(record, attr_name, options, callee) # rubocop:disable Metrics/AbcSize
|
21
|
-
|
23
|
+
if options[:value]
|
24
|
+
return options[:value].call(record) if options[:value].is_a? Proc
|
25
|
+
|
26
|
+
return options[:value]
|
27
|
+
end
|
22
28
|
|
23
29
|
args = options[:args] || []
|
24
30
|
value = record.public_send(attr_name, *args)
|
@@ -31,11 +37,11 @@ module ActiveRecordToHash
|
|
31
37
|
ActiveRecordToHash.to_a(options[:scope]).each do |scope|
|
32
38
|
value = ActiveRecordToHash.call_scope(value, scope)
|
33
39
|
end
|
34
|
-
return value.public_send(callee, options.except(:alter)) if value.is_a? ::ActiveRecord
|
40
|
+
return value.public_send(callee, options.except(:alter)) if value.is_a? ::ActiveRecordToHash::ActiveRecord
|
35
41
|
|
36
42
|
if value.is_a?(Array) || value.is_a?(::ActiveRecord::Relation)
|
37
43
|
return value.map do |obj|
|
38
|
-
next obj.public_send(callee, options.except(:alter)) if obj.is_a? ::ActiveRecord
|
44
|
+
next obj.public_send(callee, options.except(:alter)) if obj.is_a? ::ActiveRecordToHash::ActiveRecord
|
39
45
|
|
40
46
|
obj
|
41
47
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecordToHash
|
2
4
|
class Railtie < ::Rails::Railtie
|
3
5
|
config.active_record_to_hash = ActiveSupport::OrderedOptions.new
|
@@ -8,7 +10,7 @@ module ActiveRecordToHash
|
|
8
10
|
require 'active_record_to_hash/version'
|
9
11
|
require 'active_record_to_hash/utilities'
|
10
12
|
require 'active_record_to_hash/active_record'
|
11
|
-
::ActiveRecord::Base.
|
13
|
+
::ActiveRecord::Base.include ::ActiveRecordToHash::ActiveRecord
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_to_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masamoto Miyata
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.0'
|
20
20
|
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 6.1.4.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.0'
|
30
30
|
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 6.1.4.4
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: database_cleaner
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,48 +128,62 @@ dependencies:
|
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rspec
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3.10'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '3.10'
|
131
145
|
- !ruby/object:Gem::Dependency
|
132
146
|
name: rspec-rails
|
133
147
|
requirement: !ruby/object:Gem::Requirement
|
134
148
|
requirements:
|
135
|
-
- - "
|
149
|
+
- - ">="
|
136
150
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
151
|
+
version: '0'
|
138
152
|
type: :development
|
139
153
|
prerelease: false
|
140
154
|
version_requirements: !ruby/object:Gem::Requirement
|
141
155
|
requirements:
|
142
|
-
- - "
|
156
|
+
- - ">="
|
143
157
|
- !ruby/object:Gem::Version
|
144
|
-
version: '
|
158
|
+
version: '0'
|
145
159
|
- !ruby/object:Gem::Dependency
|
146
160
|
name: rubocop
|
147
161
|
requirement: !ruby/object:Gem::Requirement
|
148
162
|
requirements:
|
149
|
-
- -
|
163
|
+
- - '='
|
150
164
|
- !ruby/object:Gem::Version
|
151
|
-
version: 0.
|
165
|
+
version: 0.75.0
|
152
166
|
type: :development
|
153
167
|
prerelease: false
|
154
168
|
version_requirements: !ruby/object:Gem::Requirement
|
155
169
|
requirements:
|
156
|
-
- -
|
170
|
+
- - '='
|
157
171
|
- !ruby/object:Gem::Version
|
158
|
-
version: 0.
|
172
|
+
version: 0.75.0
|
159
173
|
- !ruby/object:Gem::Dependency
|
160
|
-
name: rubocop-
|
174
|
+
name: rubocop-rails
|
161
175
|
requirement: !ruby/object:Gem::Requirement
|
162
176
|
requirements:
|
163
|
-
- - "
|
177
|
+
- - ">="
|
164
178
|
- !ruby/object:Gem::Version
|
165
|
-
version:
|
179
|
+
version: '0'
|
166
180
|
type: :development
|
167
181
|
prerelease: false
|
168
182
|
version_requirements: !ruby/object:Gem::Requirement
|
169
183
|
requirements:
|
170
|
-
- - "
|
184
|
+
- - ">="
|
171
185
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
186
|
+
version: '0'
|
173
187
|
- !ruby/object:Gem::Dependency
|
174
188
|
name: sqlite3
|
175
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,7 +217,7 @@ homepage: https://github.com/gomo/active_record_to_hash
|
|
203
217
|
licenses:
|
204
218
|
- MIT
|
205
219
|
metadata: {}
|
206
|
-
post_install_message:
|
220
|
+
post_install_message:
|
207
221
|
rdoc_options: []
|
208
222
|
require_paths:
|
209
223
|
- lib
|
@@ -211,15 +225,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
225
|
requirements:
|
212
226
|
- - ">="
|
213
227
|
- !ruby/object:Gem::Version
|
214
|
-
version:
|
228
|
+
version: 2.6.0
|
215
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
230
|
requirements:
|
217
231
|
- - ">="
|
218
232
|
- !ruby/object:Gem::Version
|
219
233
|
version: '0'
|
220
234
|
requirements: []
|
221
|
-
rubygems_version: 3.
|
222
|
-
signing_key:
|
235
|
+
rubygems_version: 3.2.32
|
236
|
+
signing_key:
|
223
237
|
specification_version: 4
|
224
238
|
summary: Add the `to_hash` function to active record.
|
225
239
|
test_files: []
|