Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify array resource constant registration to use Avo namespace #3685

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/avo/resources/array_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ArrayResource < Base

class << self
def model_class
@@model_class ||= Object.const_set(
@@model_class ||= Avo.const_set(
class_name,
Class.new do
include ActiveModel::Model
Expand Down Expand Up @@ -68,7 +68,7 @@ def fetch_records(array_of_records = nil)
# Dynamically create a class with accessors for all unique keys from the records
keys = array_of_records.flat_map(&:keys).uniq

Object.const_set(
Avo.const_set(
class_name,
Class.new do
include ActiveModel::Model
Expand All @@ -82,7 +82,7 @@ def fetch_records(array_of_records = nil)
end
)

custom_class = class_name.constantize
custom_class = "Avo::#{class_name}".constantize

# Map the records to instances of the dynamically created class
array_of_records.map do |item|
Expand Down
Loading