Skip to content

Commit

Permalink
Fix compatibility with Rails 7.2.0.alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Feb 28, 2024
1 parent c6a5c74 commit ffa7db3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['2.7', '3.0', '3.1', '3.2']
rails: ['6.1', '7.0', 'edge']
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
rails: ['6.1', '7.0', '7.1', 'edge']
timezone_aware: [0, 1]
exclude:
- ruby: '3.2'
Expand Down
5 changes: 5 additions & 0 deletions gemfiles/Gemfile.ar-7.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gemspec path: '..'

gem 'activerecord', '~> 7.0.0'
7 changes: 6 additions & 1 deletion lib/active_record/typed_store/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def typed_store(store_attribute, options={}, &block)
typed_klass = TypedHash.create(dsl.fields.values)
const_set("#{store_attribute}_hash".camelize, typed_klass)

if ActiveRecord.version >= Gem::Version.new('6.1.0.alpha')
if ActiveRecord.version >= Gem::Version.new('7.2.0.alpha')
decorate_attributes([store_attribute]) do |name, subtype|
subtype = subtype.subtype if subtype.is_a?(Type)
Type.new(typed_klass, dsl.coder, subtype)
end
elsif ActiveRecord.version >= Gem::Version.new('6.1.0.alpha')
attribute(store_attribute) do |subtype|
subtype = subtype.subtype if subtype.is_a?(Type)
Type.new(typed_klass, dsl.coder, subtype)
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
Time.zone = 'UTC'

if ActiveRecord.respond_to?(:yaml_column_permitted_classes)
ActiveRecord.yaml_column_permitted_classes |= ['Date', 'Time', 'BigDecimal']
ActiveRecord.yaml_column_permitted_classes |= [Date, Time, BigDecimal]
elsif ActiveRecord::Base.respond_to?(:yaml_column_permitted_classes)
ActiveRecord::Base.yaml_column_permitted_classes |= ['Date', 'Time', 'BigDecimal']
ActiveRecord::Base.yaml_column_permitted_classes |= [Date, Time, BigDecimal]
end

RSpec.configure do |config|
Expand Down

0 comments on commit ffa7db3

Please sign in to comment.