rails_compatibility 0.0.8 → 0.0.10

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: e10843554c7729ecd8fb3b9ef7418fc458cb92ad18da1f4e6ce2829dd5ab1566
4
- data.tar.gz: bdea2e8109abd52b32df8ca66675bc6ae3cd9a5ad3c6e1b73081d0344526e25b
3
+ metadata.gz: 1ae3335675fb2e62fdde027f2a746d12ee1981060673b6a6353f44117ee04d44
4
+ data.tar.gz: 21e379f9fcc405a483b86f611557c99fc5cc8b2d673a87dfabbbd8a4993dbd85
5
5
  SHA512:
6
- metadata.gz: f80ced4f5e1e7c22d04262c170fb478d46aa17c02a767cc37af0b4f170e634de81d1bf6824857e4f41bbeed846eb7365b28ee670e11262dd3da0b457ea2ea06e
7
- data.tar.gz: b30469894f18200d7d102ddfe9f0308cda268c66236da7f7b6c6f53827a41616f03a871d92da95f89cd903485c139415ef0637c5c3605778fc928b9ebb661277
6
+ metadata.gz: 7b4e625f2d9f898d255f09bc65b09c1c29a02655bd2922c8fd64a9563dfcedf5f3aa18b26af9b9ff870bebfbced78d5f0ef7c97f0265b67081e336509308c285
7
+ data.tar.gz: 0d8809adf7a565d3c37946a6a30944b9ada9bb0f926bff81d30fc5ece41f1b45b52865afe92dcf6758e18d74bb38345bef99b3076bb917a94b1abd794548f31a
@@ -20,7 +20,7 @@ jobs:
20
20
  fail-fast: false
21
21
  matrix:
22
22
  ruby:
23
- - 2.2
23
+ - 2.3
24
24
  - 2.6
25
25
  - 2.7
26
26
  - 3.0
@@ -62,11 +62,11 @@ jobs:
62
62
  - gemfile: 5.2.gemfile
63
63
  ruby: 3.1
64
64
  - gemfile: 6.0.gemfile
65
- ruby: 2.2
65
+ ruby: 2.3
66
66
  - gemfile: 6.1.gemfile
67
- ruby: 2.2
67
+ ruby: 2.3
68
68
  - gemfile: 7.0.gemfile
69
- ruby: 2.2
69
+ ruby: 2.3
70
70
  - gemfile: 7.0.gemfile
71
71
  ruby: 2.6
72
72
  env:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## Change Log
2
2
 
3
+ ### [v0.0.9](https://github.com/khiav223577/rails_compatibility/compare/v0.0.8...v0.0.9) 2023/07/30
4
+ - [#17](https://github.com/khiav223577/rails_compatibility/pull/17) Implement #cast_values (@khiav223577)
5
+
6
+ ### [v0.0.8](https://github.com/khiav223577/rails_compatibility/compare/v0.0.7...v0.0.8) 2022/01/21
7
+ - [#16](https://github.com/khiav223577/rails_compatibility/pull/16) Implement #setup_autoload_paths (@khiav223577)
8
+ - [#15](https://github.com/khiav223577/rails_compatibility/pull/15) Support Rails 7.0 (@khiav223577)
9
+ - [#14](https://github.com/khiav223577/rails_compatibility/pull/14) Support Ruby 3.1 (@khiav223577)
10
+ - [#13](https://github.com/khiav223577/rails_compatibility/pull/13) Support Ruby 3.0 (@khiav223577)
11
+
3
12
  ### [v0.0.7](https://github.com/khiav223577/rails_compatibility/compare/v0.0.6...v0.0.7) 2021/06/10
4
13
  - [#12](https://github.com/khiav223577/rails_compatibility/pull/12) Implement #apply_join_dependency (@khiav223577)
5
14
 
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Test Coverage](https://codeclimate.com/github/khiav223577/rails_compatibility/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/rails_compatibility/coverage)
8
8
 
9
9
  ## Supports
10
- - Ruby 2.2 ~ 2.7, 3.0 ~ 3.1
10
+ - Ruby 2.3 ~ 2.7, 3.0 ~ 3.1
11
11
  - Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0
12
12
 
13
13
  ## Installation
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_compatibility'
4
+ require 'rails_compatibility/active_record'
5
+ require 'rails_compatibility/attribute_types'
6
+ require 'rails_compatibility/deserialize'
7
+
8
+ class << RailsCompatibility
9
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.0.6')
10
+ # Rails 7.0.6 changes parameter handling. Details at: https://github.com/rails/rails/pull/45783
11
+ def cast_values(klass, result)
12
+ attribute_types = self.attribute_types(klass)
13
+
14
+ result.map do |attributes| # This map behaves different to array#map
15
+ attributes.each_with_index do |(key, attribute), index|
16
+ attributes[key] = deserialize(result.send(:column_type, key, index, attribute_types), attribute)
17
+ end
18
+
19
+ next attributes
20
+ end
21
+ end
22
+ elsif GTE_RAILS_4_0
23
+ def cast_values(klass, result)
24
+ attribute_types = self.attribute_types(klass)
25
+
26
+ result.map do |attributes| # This map behaves different to array#map
27
+ attributes.each do |key, attribute|
28
+ attributes[key] = deserialize(result.send(:column_type, key, attribute_types), attribute)
29
+ end
30
+
31
+ next attributes
32
+ end
33
+ end
34
+ else
35
+ def cast_values(klass, result)
36
+ result.map! do |attributes| # This map! behaves different to array#map!
37
+ initialized_attributes = klass.initialize_attributes(attributes)
38
+ attributes.each do |key, _attribute|
39
+ attributes[key] = klass.type_cast_attribute(key, initialized_attributes)
40
+ end
41
+
42
+ next attributes
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_compatibility'
4
+ require 'rails_compatibility/active_record'
5
+
6
+ class << RailsCompatibility
7
+ if GTE_RAILS_5_0
8
+ # type_cast_from_database was changed to deserialize in Rails 5
9
+ def deserialize(type, attribute)
10
+ type.deserialize(attribute)
11
+ end
12
+ else
13
+ def deserialize(type, attribute)
14
+ type.type_cast_from_database(attribute)
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsCompatibility
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_compatibility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-21 00:00:00.000000000 Z
11
+ date: 2023-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -132,7 +132,9 @@ files:
132
132
  - lib/rails_compatibility/apply_join_dependency.rb
133
133
  - lib/rails_compatibility/attribute_types.rb
134
134
  - lib/rails_compatibility/build_joins.rb
135
+ - lib/rails_compatibility/cast_values.rb
135
136
  - lib/rails_compatibility/construct_join_dependency.rb
137
+ - lib/rails_compatibility/deserialize.rb
136
138
  - lib/rails_compatibility/has_include.rb
137
139
  - lib/rails_compatibility/pick.rb
138
140
  - lib/rails_compatibility/setup_autoload_paths.rb