Skip to content

Commit

Permalink
Fix compatibility with Rails 8.0.0alpha
Browse files Browse the repository at this point in the history
Decorating `class_attribute` has always been wonky.
I'm not 100% certain I'll go through with the Rails change,
but it's best if we don't rely on it.

We don't need to cache the file_path anyway.
  • Loading branch information
byroot committed Aug 27, 2024
1 parent 26486ca commit 958d9a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Fix compatibility with Rails 8.0.0alpha: https://github.com/rails/rails/pull/52717

# v0.27.2

- Fix a Ruby warning that was emitted when `frozen_record` is loaded.
Expand Down
19 changes: 5 additions & 14 deletions lib/frozen_record/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ def primary_key=(primary_key)
set_primary_key(-primary_key.to_s)
end

alias_method :set_base_path, :base_path=
private :set_base_path
def base_path=(base_path)
@file_path = nil
set_base_path(base_path)
end

attr_accessor :abstract_class

def attributes
Expand Down Expand Up @@ -115,13 +108,11 @@ def current_scope=(scope)

def file_path
raise ArgumentError, "You must define `#{name}.base_path`" unless base_path
@file_path ||= begin
file_path = File.join(base_path, backend.filename(name))
if !File.exist?(file_path) && File.exist?("#{file_path}.erb")
"#{file_path}.erb"
else
file_path
end
file_path = File.join(base_path, backend.filename(name))
if !File.exist?(file_path) && File.exist?("#{file_path}.erb")
"#{file_path}.erb"
else
file_path
end
end

Expand Down

0 comments on commit 958d9a6

Please sign in to comment.