active_record_to_hash 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +237 -0
- data/Rakefile +17 -0
- data/lib/active_record_to_hash.rb +17 -0
- data/lib/active_record_to_hash/active_record.rb +31 -0
- data/lib/active_record_to_hash/utilities.rb +74 -0
- data/lib/active_record_to_hash/version.rb +3 -0
- data/lib/tasks/active_record_to_hash_tasks.rake +4 -0
- metadata +225 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 348e5277a6af88cfd52397ab8b50e5a945c3eb8a6db670fe5e18fd4e1e65027c
|
4
|
+
data.tar.gz: 7a49b75739ccf0270184181c630c00e661159ce214180e1f774c8c96bb797ef9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06b65646b336a5082d5738fa9088dc74076fb94ac6de453718c3550f9f09c47c33267bf45b69e76ca14ee70e38099952cfe1419e9a62f826a3655ffc9e7abbe8
|
7
|
+
data.tar.gz: f420f96cb01629325d57acf1891883aabe03ced09bec07210f2cada6b49c07d4b9546ef63862c4cd830f75ea4f99df9e64d2ea1de93f64c550a88d0a44cf22de
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Masamoto Miyata
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
# ActiveRecordToHash
|
2
|
+
|
3
|
+
## Summary
|
4
|
+
|
5
|
+
Add `to_hash` method to ActiveRecord of Rails. The `to_hash` method can also acquire related records with relations by Hash, by passing the options to the argument.You can filter the values to retrieve, and change the keys of Hash using options.
|
6
|
+
|
7
|
+
ActiveRecordToHash will be useful when creating a Web API that returns a response with JSON.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```
|
12
|
+
gem 'active_record_to_hash', '~>0.1'
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
### Options
|
19
|
+
|
20
|
+
| Key | Description | Type |
|
21
|
+
|:--|:--|:--|
|
22
|
+
| attrs_reader | Specify a method to get the hash of the value and column name. If you omitt it, `attributes` is used. | Symbol |
|
23
|
+
| key | Change the key of the hash. | Symbol |
|
24
|
+
| except | Remove from the hash. | Symbol Array |
|
25
|
+
| only | Retrieve only the specified key. | Symbol Array |
|
26
|
+
| with_[attribute_name] | The attribute name is passed to public_send. If the return value is ActiveRecord or ActiveRecord_Relation, call `to_hash`. The Hash specified for this value is passed to that `to_hash`. | Boolean Hash :exists |
|
27
|
+
| scope | You can specify scope when acquiring related records. | Symbol Array Proc |
|
28
|
+
|
29
|
+
|
30
|
+
### Examples
|
31
|
+
|
32
|
+
Examples are shown assuming the following tables.
|
33
|
+
|
34
|
+
```rb
|
35
|
+
create_table :wide_areas do |t|
|
36
|
+
t.string :name
|
37
|
+
t.timestamps
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table :areas do |t|
|
41
|
+
t.string :name
|
42
|
+
t.references :wide_area, foreign_key: true
|
43
|
+
t.timestamps
|
44
|
+
end
|
45
|
+
|
46
|
+
create_table :shops do |t|
|
47
|
+
t.string :name
|
48
|
+
t.timestamps
|
49
|
+
end
|
50
|
+
|
51
|
+
create_table :shop_areas do |t|
|
52
|
+
t.references :shop, foreign_key: true
|
53
|
+
t.references :area, foreign_key: true
|
54
|
+
t.timestamps
|
55
|
+
end
|
56
|
+
|
57
|
+
class Shop < ApplicationRecord
|
58
|
+
has_many :shop_areas
|
59
|
+
has_many :areas, inverse_of: :shops, through: :shop_areas
|
60
|
+
|
61
|
+
def to_api_hash
|
62
|
+
{
|
63
|
+
id: id,
|
64
|
+
name: name
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
```rb
|
71
|
+
p shop.to_hash
|
72
|
+
# {
|
73
|
+
# :id=>1,
|
74
|
+
# :name=>"Shop No1",
|
75
|
+
# :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00,
|
76
|
+
# :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00
|
77
|
+
# }
|
78
|
+
|
79
|
+
p shop.to_hash(attrs_reader: to_api_hash)
|
80
|
+
# {
|
81
|
+
# :id=>1,
|
82
|
+
# :name=>"Shop No1",
|
83
|
+
# }
|
84
|
+
|
85
|
+
p shop.to_hash(attrs_reader: ->(shop){ {shop_id: shop.id} })
|
86
|
+
# {
|
87
|
+
# :shop_id=>1,
|
88
|
+
# }
|
89
|
+
|
90
|
+
p shop.to_hash(only: :name)
|
91
|
+
# {:name => "Shop No1"}
|
92
|
+
|
93
|
+
p shop.to_hash(except: [:created_at, :updated_at])
|
94
|
+
# {:id => 1, :name => "Shop No1"}
|
95
|
+
|
96
|
+
p shop.to_hash(only: [:id], with_name: {key: :foobar})
|
97
|
+
# {:id=>1, :foobar=>"Shop No1"}
|
98
|
+
|
99
|
+
p shop.to_hash(only: [:id, :name], with_areas: true)
|
100
|
+
# {
|
101
|
+
# :id=>1,
|
102
|
+
# :name=>"Shop No1",
|
103
|
+
# :areas=>[
|
104
|
+
# {:id=>1, :name=>"Area No1", :wide_area_id=>1, :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00, :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00},
|
105
|
+
# {:id=>2, :name=>"Area No2", :wide_area_id=>2, :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00, :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00},
|
106
|
+
# {:id=>3, :name=>"Area No3", :wide_area_id=>3, :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00, :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00}
|
107
|
+
# ]
|
108
|
+
# }
|
109
|
+
|
110
|
+
p shop.to_hash(only: [:id, :name], with_areas: false)
|
111
|
+
# {
|
112
|
+
# :id=>1,
|
113
|
+
# :name=>"Shop No1"
|
114
|
+
# }
|
115
|
+
|
116
|
+
p shop.to_hash(only: [:id, :name], with_areas: {key: :area_list})
|
117
|
+
# {
|
118
|
+
# :id=>1,
|
119
|
+
# :name=>"Shop No1",
|
120
|
+
# :area_list=>[
|
121
|
+
# {:id=>1, :name=>"Area No1", :wide_area_id=>1, :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00, :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00},
|
122
|
+
# {:id=>2, :name=>"Area No2", :wide_area_id=>2, :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00, :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00},
|
123
|
+
# {:id=>3, :name=>"Area No3", :wide_area_id=>3, :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00, :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00}
|
124
|
+
# ]
|
125
|
+
# }
|
126
|
+
|
127
|
+
p shop.to_hash(only: [:id, :name], with_areas: {scope: ->{ where(id: 1) }})
|
128
|
+
# {
|
129
|
+
# :id=>1,
|
130
|
+
# :name=>"Shop No1",
|
131
|
+
# :areas=>[
|
132
|
+
# {:id=>1, :name=>"Area No1", :wide_area_id=>1, :created_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00, :updated_at=>Mon, 26 Mar 2018 07:53:26 UTC +00:00}
|
133
|
+
# ]
|
134
|
+
# }
|
135
|
+
|
136
|
+
p shop.to_hash(
|
137
|
+
only: [:id, :name],
|
138
|
+
with_areas: {
|
139
|
+
only: [:id, :name],
|
140
|
+
with_wide_area: {
|
141
|
+
only: [:id, :name]
|
142
|
+
}
|
143
|
+
}
|
144
|
+
)
|
145
|
+
# {
|
146
|
+
# :id=>1,
|
147
|
+
# :name=>"Shop No1",
|
148
|
+
# :areas=>[
|
149
|
+
# {:id=>1, :name=>"Area No1", :wide_area=>{:id=>1, :name=>"Wide Area No1"}},
|
150
|
+
# {:id=>2, :name=>"Area No2", :wide_area=>{:id=>2, :name=>"Wide Area No2"}},
|
151
|
+
# {:id=>3, :name=>"Area No3", :wide_area=>{:id=>3, :name=>"Wide Area No3"}}
|
152
|
+
# ]
|
153
|
+
# }
|
154
|
+
|
155
|
+
|
156
|
+
p shop.to_hash(
|
157
|
+
only: [:id, :name],
|
158
|
+
with_areas: {
|
159
|
+
alter: ->(areas){ areas.each_with_object({}) {|area, memo| memo[area[:id]] = area[:name] } }
|
160
|
+
}
|
161
|
+
)
|
162
|
+
# {
|
163
|
+
# :id=>1,
|
164
|
+
# :name=>"Shop No1",
|
165
|
+
# :areas=>{1=>"Area No1", 2=>"Area No2", 3=>"Area No3"}
|
166
|
+
# }
|
167
|
+
|
168
|
+
p shop.to_hash(only: [:id, :name], with_areas: :exists)
|
169
|
+
# {:id=>1, :name=>"Shop No1", :areas=>true}
|
170
|
+
# You can use this option only with ActiveRecord::Relation
|
171
|
+
|
172
|
+
```
|
173
|
+
|
174
|
+
### Configuration
|
175
|
+
|
176
|
+
#### method_name
|
177
|
+
|
178
|
+
You can change the method name from `:to_hash` to you want.
|
179
|
+
|
180
|
+
```rb
|
181
|
+
# config/application.rb
|
182
|
+
module YourApp
|
183
|
+
class Application < Rails::Application
|
184
|
+
...
|
185
|
+
config.active_record_to_hash.method_name = :to_your_hash
|
186
|
+
end
|
187
|
+
end
|
188
|
+
```
|
189
|
+
|
190
|
+
#### aliases
|
191
|
+
|
192
|
+
You can set an aliases for the method.
|
193
|
+
|
194
|
+
```rb
|
195
|
+
# config/application.rb
|
196
|
+
module YourApp
|
197
|
+
class Application < Rails::Application
|
198
|
+
...
|
199
|
+
config.active_record_to_hash.aliases = [:to_api_hash]
|
200
|
+
end
|
201
|
+
end
|
202
|
+
```
|
203
|
+
|
204
|
+
This is useful for overriding and preparing hashed methods of various patterns. The same alias method is also called for the related record specified in `with_[attribute_name]` option.
|
205
|
+
|
206
|
+
```rb
|
207
|
+
# app/model/application_record.rb
|
208
|
+
|
209
|
+
def to_api_hash(options = {})
|
210
|
+
options = {
|
211
|
+
except: [:created_at, :updated_at, :sequence],
|
212
|
+
attrs_reader: :attributes_for_api
|
213
|
+
}.merge(options)
|
214
|
+
|
215
|
+
super(options)
|
216
|
+
end
|
217
|
+
|
218
|
+
# Time type value is converted to timestamp.
|
219
|
+
def attributes_for_api
|
220
|
+
hash = attributes.each_with_object({}.with_indifferent_access) do |(k, v), obj|
|
221
|
+
v = v.to_i if v.is_a? Time
|
222
|
+
obj[k] = v
|
223
|
+
end
|
224
|
+
hash
|
225
|
+
end
|
226
|
+
```
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
## Contributing
|
231
|
+
|
232
|
+
* Run rspec test.
|
233
|
+
* Check source code with the rubocop.
|
234
|
+
|
235
|
+
|
236
|
+
## License
|
237
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'ActiveRecordToHash'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveRecordToHash
|
2
|
+
class Railtie < ::Rails::Railtie
|
3
|
+
config.active_record_to_hash = ActiveSupport::OrderedOptions.new
|
4
|
+
config.active_record_to_hash.method_name = :to_hash
|
5
|
+
config.active_record_to_hash.aliases = []
|
6
|
+
|
7
|
+
config.after_initialize do |_app|
|
8
|
+
require 'active_record_to_hash/version'
|
9
|
+
require 'active_record_to_hash/utilities'
|
10
|
+
require 'active_record_to_hash/active_record'
|
11
|
+
::ActiveRecord::Base.send(:include, ::ActiveRecordToHash::ActiveRecord)
|
12
|
+
::Rails.application.config.active_record_to_hash.aliases.each do |alias_name|
|
13
|
+
::ActiveRecord::Base.send(:alias_method, alias_name, ::Rails.application.config.active_record_to_hash.method_name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveRecordToHash
|
2
|
+
module ActiveRecord
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
define_method ::Rails.application.config.active_record_to_hash.method_name do |options = {}|
|
7
|
+
if options[:pluck]
|
8
|
+
result = public_send(options[:pluck])
|
9
|
+
else
|
10
|
+
attrs_reader = options[:attrs_reader] || :attributes
|
11
|
+
attrs = attrs_reader.is_a?(Proc) ? attrs_reader.call(self) : public_send(attrs_reader)
|
12
|
+
result = attrs.each_with_object({}) do |(k, v), memo|
|
13
|
+
key = k.to_sym
|
14
|
+
next if ActiveRecordToHash.to_a(options[:except]).include?(key)
|
15
|
+
next if options[:only] && !ActiveRecordToHash.to_a(options[:only]).include?(key)
|
16
|
+
|
17
|
+
memo[key] = v
|
18
|
+
end
|
19
|
+
result = ActiveRecordToHash.handle_alter(result, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
ActiveRecordToHash.handle_with_options(options) do |hash_key, attr_name, child_options|
|
23
|
+
child = ActiveRecordToHash.retrieve_child_attribute(self, attr_name, child_options, __callee__)
|
24
|
+
result[hash_key] = ActiveRecordToHash.handle_alter(child, child_options)
|
25
|
+
end
|
26
|
+
|
27
|
+
result
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module ActiveRecordToHash
|
2
|
+
module_function
|
3
|
+
|
4
|
+
def call_scope(relation, scope)
|
5
|
+
if scope.is_a? Proc
|
6
|
+
ret = relation.instance_exec(&scope)
|
7
|
+
return ret || relation
|
8
|
+
end
|
9
|
+
|
10
|
+
relation.public_send(scope)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_a(value)
|
14
|
+
return value if value.is_a? Array
|
15
|
+
return [] if value.nil?
|
16
|
+
|
17
|
+
[value]
|
18
|
+
end
|
19
|
+
|
20
|
+
def retrieve_child_attribute(record, attr_name, options, callee) # rubocop:disable Metrics/AbcSize
|
21
|
+
return options[:value] if options[:value]
|
22
|
+
|
23
|
+
args = options[:args] || []
|
24
|
+
value = record.public_send(attr_name, *args)
|
25
|
+
if options[:exists]
|
26
|
+
raise 'You can use `exists` option only with ActiveRecord::Relation' unless value.is_a? ::ActiveRecord::Relation
|
27
|
+
|
28
|
+
return value.exists?
|
29
|
+
end
|
30
|
+
|
31
|
+
ActiveRecordToHash.to_a(options[:scope]).each do |scope|
|
32
|
+
value = ActiveRecordToHash.call_scope(value, scope)
|
33
|
+
end
|
34
|
+
return value.public_send(callee, options.except(:alter)) if value.is_a? ::ActiveRecord::Base
|
35
|
+
|
36
|
+
if value.is_a?(Array) || value.is_a?(::ActiveRecord::Relation)
|
37
|
+
return value.map do |obj|
|
38
|
+
next obj.public_send(callee, options.except(:alter)) if obj.is_a? ::ActiveRecord::Base
|
39
|
+
|
40
|
+
obj
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
value
|
45
|
+
end
|
46
|
+
|
47
|
+
def handle_alter(result, options)
|
48
|
+
return result if options[:alter].nil?
|
49
|
+
|
50
|
+
res = options[:alter].call(result)
|
51
|
+
return result if res.nil?
|
52
|
+
|
53
|
+
res
|
54
|
+
end
|
55
|
+
|
56
|
+
def handle_with_options(options)
|
57
|
+
options.each_key do |key|
|
58
|
+
next unless key.to_s.start_with?('with_')
|
59
|
+
next if options[key] == false
|
60
|
+
|
61
|
+
attr_name = key[5..-1].to_sym # 5 is 'with_'.length
|
62
|
+
hash_key = !options[key].is_a?(Hash) || options[key][:key].nil? ? attr_name : options[key][:key]
|
63
|
+
child_options = ActiveRecordToHash.normalize_child_options(options[key])
|
64
|
+
yield(hash_key, attr_name, child_options)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def normalize_child_options(options)
|
69
|
+
return {} if options == true
|
70
|
+
return { exists: true } if options == :exists
|
71
|
+
|
72
|
+
options
|
73
|
+
end
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_record_to_hash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masamoto Miyata
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
- - "<="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6.1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.0'
|
30
|
+
- - "<="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.1'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: database_cleaner
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.6'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.6'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: factory_bot_rails
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '4.8'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4.8'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: faker
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: pry-byebug
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: pry-doc
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: pry-rails
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: pry-stack_explorer
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rspec-rails
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3.7'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '3.7'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rubocop
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 0.67.2
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 0.67.2
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: rubocop-performance
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 1.0.0
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 1.0.0
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: sqlite3
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '1.3'
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '1.3'
|
187
|
+
description: Add a `to_hash` method that can acquire the relations to the active record.
|
188
|
+
email:
|
189
|
+
- miyata@sincere-co.com
|
190
|
+
executables: []
|
191
|
+
extensions: []
|
192
|
+
extra_rdoc_files: []
|
193
|
+
files:
|
194
|
+
- MIT-LICENSE
|
195
|
+
- README.md
|
196
|
+
- Rakefile
|
197
|
+
- lib/active_record_to_hash.rb
|
198
|
+
- lib/active_record_to_hash/active_record.rb
|
199
|
+
- lib/active_record_to_hash/utilities.rb
|
200
|
+
- lib/active_record_to_hash/version.rb
|
201
|
+
- lib/tasks/active_record_to_hash_tasks.rake
|
202
|
+
homepage: https://github.com/gomo/active_record_to_hash
|
203
|
+
licenses:
|
204
|
+
- MIT
|
205
|
+
metadata: {}
|
206
|
+
post_install_message:
|
207
|
+
rdoc_options: []
|
208
|
+
require_paths:
|
209
|
+
- lib
|
210
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
|
+
requirements:
|
217
|
+
- - ">="
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
version: '0'
|
220
|
+
requirements: []
|
221
|
+
rubygems_version: 3.0.6
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: Add the `to_hash` function to active record.
|
225
|
+
test_files: []
|