rails_compatibility 0.0.8 → 0.0.9

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: e10843554c7729ecd8fb3b9ef7418fc458cb92ad18da1f4e6ce2829dd5ab1566
4
- data.tar.gz: bdea2e8109abd52b32df8ca66675bc6ae3cd9a5ad3c6e1b73081d0344526e25b
3
+ metadata.gz: c219e0fdf9b8fd4c4eddbd1b0a14a325932b9e9b54d4e3769bc8e3cfcff1196e
4
+ data.tar.gz: 55d3190a204319f37b82a3bc8dba1fd0b8d8ee404ef1f8d562ec0f8762077f60
5
5
  SHA512:
6
- metadata.gz: f80ced4f5e1e7c22d04262c170fb478d46aa17c02a767cc37af0b4f170e634de81d1bf6824857e4f41bbeed846eb7365b28ee670e11262dd3da0b457ea2ea06e
7
- data.tar.gz: b30469894f18200d7d102ddfe9f0308cda268c66236da7f7b6c6f53827a41616f03a871d92da95f89cd903485c139415ef0637c5c3605778fc928b9ebb661277
6
+ metadata.gz: cd440b56ff89b8c8d972ede08988bb0bf83f14ab3aefef78c32eaba37500f36b9e178ef8fb1f6e6d937550bf906aab8cc9c5703d3e769f739bb0b7f6c9801bc5
7
+ data.tar.gz: 1eed03d043721a4246499686a2c701774090d9028ed9c78dd708f5658b775999421c1186802d1704c306e7478f792507ce139f15b52cf2c060d7a6373baa1b83
@@ -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,11 @@
1
1
  ## Change Log
2
2
 
3
+ ### [v0.0.8](https://github.com/khiav223577/rails_compatibility/compare/v0.0.7...v0.0.8) 2022/01/21
4
+ - [#16](https://github.com/khiav223577/rails_compatibility/pull/16) Implement #setup_autoload_paths (@khiav223577)
5
+ - [#15](https://github.com/khiav223577/rails_compatibility/pull/15) Support Rails 7.0 (@khiav223577)
6
+ - [#14](https://github.com/khiav223577/rails_compatibility/pull/14) Support Ruby 3.1 (@khiav223577)
7
+ - [#13](https://github.com/khiav223577/rails_compatibility/pull/13) Support Ruby 3.0 (@khiav223577)
8
+
3
9
  ### [v0.0.7](https://github.com/khiav223577/rails_compatibility/compare/v0.0.6...v0.0.7) 2021/06/10
4
10
  - [#12](https://github.com/khiav223577/rails_compatibility/pull/12) Implement #apply_join_dependency (@khiav223577)
5
11
 
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,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_compatibility'
4
+ require 'rails_compatibility/active_record'
5
+ require 'rails_compatibility/deserialize'
6
+
7
+ class << RailsCompatibility
8
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.0.6')
9
+ # Rails 7.0.6 changes parameter handling. Details at: https://github.com/rails/rails/pull/45783
10
+ def cast_values(klass, result)
11
+ attribute_types = self.attribute_types(klass)
12
+
13
+ result.map do |attributes| # This map behaves different to array#map
14
+ attributes.each_with_index do |(key, attribute), index|
15
+ attributes[key] = deserialize(result.send(:column_type, key, index, attribute_types), attribute)
16
+ end
17
+
18
+ next attributes
19
+ end
20
+ end
21
+ elsif GTE_RAILS_4_0
22
+ def cast_values(klass, result)
23
+ attribute_types = self.attribute_types(klass)
24
+
25
+ result.map do |attributes| # This map behaves different to array#map
26
+ attributes.each do |key, attribute|
27
+ attributes[key] = deserialize(result.send(:column_type, key, attribute_types), attribute)
28
+ end
29
+
30
+ next attributes
31
+ end
32
+ end
33
+ else
34
+ def cast_values(klass, result)
35
+ result.map! do |attributes| # This map! behaves different to array#map!
36
+ initialized_attributes = klass.initialize_attributes(attributes)
37
+ attributes.each do |key, _attribute|
38
+ attributes[key] = klass.type_cast_attribute(key, initialized_attributes)
39
+ end
40
+
41
+ next attributes
42
+ end
43
+ end
44
+ end
45
+ 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.9'
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.9
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