added persist to Array/Hash and added merge to Detached/Persisted

This commit is contained in:
Administrator 2026-03-28 22:33:46 -07:00
parent 5a08aa52eb
commit 1bd8e8fb41
4 changed files with 120 additions and 2 deletions

View file

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'gxg-framework'
s.version = '0.0.67'
s.version = '0.0.68'
s.licenses = ['HIPPOCRATIC 2.1', 'https://firstdonoharm.dev/version/2/1/license.html']
s.summary = "GxG Framework"
s.description = "GxG Framework"

View file

@ -3772,7 +3772,6 @@ class Hash
self
end
#
#
end
#
class Array
@ -4149,6 +4148,11 @@ class Array
end
#
end
# OpenStruct support for Arrays.
module GxG
class ArrayWrapper

View file

@ -5504,3 +5504,28 @@ end
require File.expand_path("./gxg_database_persistedarray.rb",File.dirname(__FILE__))
require File.expand_path("./gxg_database_persistedhash.rb",File.dirname(__FILE__))
#
class Hash
#
def persist(credential=::GxG::DB[:administrator], to_db=:data)
result = nil
database = ::GxG::DB[:roles][(to_db)]
if database.is_a?(::GxG::Database::Database)
result = database.try_persist(self, credential)
end
result
end
#
end
#
class Array
#
def persist(credential=::GxG::DB[:administrator], to_db=:data)
result = nil
database = ::GxG::DB[:roles][(to_db)]
if database.is_a?(::GxG::Database::Database)
result = database.try_persist(self, credential)
end
result
end
#
end

View file

@ -965,6 +965,50 @@ module GxG
result
end
#
def merge!(input_object=nil, options={})
result = self
if input_object.is_any?(::Hash, ::GxG::Database::DetachedHash, ::GxG::Database::PersistedHash)
#
if @format
# merge only keys common to both
input_object.keys.each do |import_key|
if result.keys.include?(import_key)
result[(import_key)] = input_object[(import_key)]
end
end
else
input_object.keys.each do |import_key|
result[(import_key)] = input_object[(import_key)]
end
end
#
end
result
end
#
def merge(input_object=nil, options={})
result = self
if input_object.is_any?(::Hash, ::GxG::Database::DetachedHash, ::GxG::Database::PersistedHash)
result = ::GxG::Database::DetachedHash::iterative_detached_persist(self.unpersist)
#
if @format
# merge only keys common to both
input_object.keys.each do |import_key|
if result.keys.include?(import_key)
result[(import_key)] = input_object[(import_key)]
end
end
result.format = @format
else
input_object.keys.each do |import_key|
result[(import_key)] = input_object[(import_key)]
end
end
#
end
result
end
#
end
#
class PersistedHash
@ -2849,6 +2893,51 @@ module GxG
result
end
#
def merge!(input_object=nil, options={})
result = self
if input_object.is_any?(::Hash, ::GxG::Database::DetachedHash, ::GxG::Database::PersistedHash)
#
if @format
# merge only keys common to both
input_object.keys.each do |import_key|
if result.keys.include?(import_key)
result[(import_key)] = input_object[(import_key)]
end
end
else
input_object.keys.each do |import_key|
result[(import_key)] = input_object[(import_key)]
end
end
#
end
result
end
#
def merge(input_object=nil, options={})
result = self
if input_object.is_any?(::Hash, ::GxG::Database::DetachedHash, ::GxG::Database::PersistedHash)
#
result = ::GxG::Database::DetachedHash::iterative_detached_persist(self.unpersist)
#
if @format
# merge only keys common to both
input_object.keys.each do |import_key|
if self.keys.include?(import_key)
result[(import_key)] = input_object[(import_key)]
end
end
result.format = @format
else
input_object.keys.each do |import_key|
result[(import_key)] = input_object[(import_key)]
end
end
#
end
result
end
#
end
end
end