Skip to content

Commit

Permalink
fix: modify array resource constant registration to use Avo namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Feb 21, 2025
1 parent 9f81a6c commit 8d4d27a
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 8d4d27a

Please sign in to comment.