From 1117f237adce4462d14caf50a966848fd37e7d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Gonc=CC=A7alves?= Date: Thu, 14 Nov 2024 10:39:21 +0000 Subject: [PATCH] Added support for rails 8 --- CHANGELOG.md | 4 ++++ lib/rabl.rb | 6 +++--- lib/rabl/engine.rb | 4 ++-- lib/rabl/railtie.rb | 2 +- lib/rabl/template.rb | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 449efe13..8797a103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## unreleased + +* Support for Rails 8 (@basex) + ## 0.16.1 (Oct 10, 2022) * Fix ArgumentError when there are no keyword arguments for Ruby < 2.7 (Thanks @sylvain-8422) diff --git a/lib/rabl.rb b/lib/rabl.rb index 06c2f564..02630be3 100644 --- a/lib/rabl.rb +++ b/lib/rabl.rb @@ -17,9 +17,9 @@ require 'rabl/cache_engine' if defined?(Rails) && Rails.respond_to?(:version) - require 'rabl/tracker' if Rails.version =~ /^[4567]/ - require 'rabl/digestor' if Rails.version =~ /^[4567]/ - require 'rabl/railtie' if Rails.version =~ /^[34567]/ + require 'rabl/tracker' if Rails.version =~ /^[45678]/ + require 'rabl/digestor' if Rails.version =~ /^[45678]/ + require 'rabl/railtie' if Rails.version =~ /^[345678]/ end # Rabl.register! diff --git a/lib/rabl/engine.rb b/lib/rabl/engine.rb index ae52f9b3..24b2121e 100644 --- a/lib/rabl/engine.rb +++ b/lib/rabl/engine.rb @@ -62,7 +62,7 @@ def cache_key template = @_options[:template] || @virtual_path digest = - if Rails.version.to_s =~ /^[67]/ + if Rails.version.to_s =~ /^[678]/ Digestor.digest(name: template, finder: lookup_context, format: :rabl) elsif Gem::Version.new(Rails.version) >= Gem::Version.new('4.1') Digestor.digest(:name => template, :finder => lookup_context) @@ -399,7 +399,7 @@ def cache_results(&block) end def digestor_available? - defined?(Rails) && Rails.version =~ /^[4567]/ + defined?(Rails) && Rails.version =~ /^[45678]/ end def valid_format?(format) diff --git a/lib/rabl/railtie.rb b/lib/rabl/railtie.rb index 19bab0f3..22601d77 100644 --- a/lib/rabl/railtie.rb +++ b/lib/rabl/railtie.rb @@ -22,7 +22,7 @@ module ApiRendering Rabl.register! # Inject dependency tracker for :rabl - if Rails.version =~ /^[4567]/ + if Rails.version =~ /^[45678]/ require 'action_view/dependency_tracker' ActionView::DependencyTracker.register_tracker :rabl, Rabl::Tracker end diff --git a/lib/rabl/template.rb b/lib/rabl/template.rb index 6942b195..282d8a37 100644 --- a/lib/rabl/template.rb +++ b/lib/rabl/template.rb @@ -62,8 +62,8 @@ def self.call(template) ActionView::Template.register_template_handler :rabl, ActionView::Template::Handlers::Rabl end -# Rails 6.X / 7.X Template -if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^[67]/ +# Rails 6.X / 7.X / 8.X Template +if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^[678]/ module ActionView module Template::Handlers class Rabl