Skip to content

Commit

Permalink
added support for rails 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipe Gonçalves committed Nov 12, 2024
1 parent e1655d4 commit 1c45233
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/rabl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
4 changes: 2 additions & 2 deletions lib/rabl/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/rabl/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/rabl/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c45233

Please sign in to comment.