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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e8bbf44746f19ae03204f3238d41433e302883bc243765972a1a069ab005845
4
- data.tar.gz: a83790ab70b421afc22c71439e7ea98e00998268eba7853eb2310269039b9920
3
+ metadata.gz: d58db5d3bc83a1c3d5aeacc76b93c4a74170cd56f4ccce73a7c2fbda1c231bad
4
+ data.tar.gz: a386699d79c74de0ea5a1f6446544ac90a61c56b355abff1bb17b40c1f1a1f52
5
5
  SHA512:
6
- metadata.gz: fe083b2d28d5751e5ca19cabf36cd4d8b82c17e88a6e9c703c0d56dfe16ea8b0f46eeed46629f06c11cfd2fbd684b3c9bfc22c1608f44545c4542287b53f6892
7
- data.tar.gz: 178ba98dee7b6e7a9865cb998a21f99b2860affbf5553677971a079726370aa1d8af625ee62821d390b1e53178b8de446af97eed177aac9ef91f657eda7fbc49
6
+ metadata.gz: 9131d35e459532105d66f8144d73c152a6f0a66f1f1e366ddfdbacd34b6ee223c1b6457ce03682be00323db915ed09eadabda846ad5056c7aaac61b0e8e1dfca
7
+ data.tar.gz: 5ca180e0781e2bad5bfc98a697394ee44d6c9ab87a8222e81bc25041810af1df57cd291962a9f3529edee7ae3c8c63e92e17ca6ff27c2654f7699d5a5defc06d
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecordToHash
2
4
  module ActiveRecord
3
5
  extend ActiveSupport::Concern
@@ -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
- return options[:value] if options[:value]
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::Base
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::Base
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
- VERSION = '0.6.0'.freeze
4
+ VERSION = '1.1.0'
3
5
  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.send(:include, ::ActiveRecordToHash::ActiveRecord)
13
+ ::ActiveRecord::Base.include ::ActiveRecordToHash::ActiveRecord
12
14
  end
13
15
  end
14
16
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # desc "Explaining what the task does"
2
3
  # task :active_record_to_hash do
3
4
  # # Task goes here
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: 0.6.0
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: 2021-07-02 00:00:00.000000000 Z
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: '6.1'
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: '6.1'
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: '3.7'
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: '3.7'
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.67.2
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.67.2
172
+ version: 0.75.0
159
173
  - !ruby/object:Gem::Dependency
160
- name: rubocop-performance
174
+ name: rubocop-rails
161
175
  requirement: !ruby/object:Gem::Requirement
162
176
  requirements:
163
- - - "~>"
177
+ - - ">="
164
178
  - !ruby/object:Gem::Version
165
- version: 1.0.0
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: 1.0.0
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: '0'
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.0.6
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: []