Added merge to Hash/Detached/Persisted

This commit is contained in:
Administrator 2026-03-29 08:16:47 -07:00
parent 1bd8e8fb41
commit 2a32efd9a7
2 changed files with 18 additions and 15 deletions

View file

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

View file

@ -2914,16 +2914,18 @@ module GxG
result result
end end
# #
def merge(input_object=nil, options={}) def merge(input_object=nil, options={:role => :data, :credential => ::GxG::DB[:administrator]})
result = self result = nil
if input_object.is_any?(::Hash, ::GxG::Database::DetachedHash, ::GxG::Database::PersistedHash) if input_object.is_any?(::Hash, ::GxG::Database::DetachedHash, ::GxG::Database::PersistedHash)
# #
result = ::GxG::Database::DetachedHash::iterative_detached_persist(self.unpersist) database = ::GxG::DB[:roles][(options[:role] || :data)]
if database.is_a?(::GxG::Database::Database)
result = database.try_persist({}, (options[:credential] || ::GxG::DB[:administrator]))
# #
if @format if @format
# merge only keys common to both # merge only keys common to both
input_object.keys.each do |import_key| self.keys.each do |import_key|
if self.keys.include?(import_key) if input_object.keys.include?(import_key)
result[(import_key)] = input_object[(import_key)] result[(import_key)] = input_object[(import_key)]
end end
end end
@ -2935,6 +2937,7 @@ module GxG
end end
# #
end end
end
result result
end end
# #