Init dump

This commit is contained in:
Jason Jordan
2025-11-24 08:22:44 -05:00
parent d48bb96791
commit 3fbece7da6
73 changed files with 1747 additions and 121 deletions
+23
View File
@@ -0,0 +1,23 @@
class ArrayOfItemsType < ActiveModel::Type::Value
# The `cast` method is used to convert an incoming value into the desired type.
def cast(value)
return unless value.present?
Array.wrap(value).map do |item_data|
# Assuming item_data is a hash, this creates an instance of the Item class.
# You can modify this part to match your object's initializer.
if item_data.is_a?(Hash)
Item.new(item_data)
else
item_data # Return the item as-is if it's already an object
end
end
end
# This method is used when defining the type to convert it to a string for serialization.
def serialize(value)
value
end
end
ActiveModel::Type.register(:array_of_items, ArrayOfItemsType)