mirror of
https://github.com/mistergibson/gxg-framework.git
synced 2026-08-15 03:46:00 -07:00
Added merge to Hash/Detached/Persisted
This commit is contained in:
parent
1bd8e8fb41
commit
2a32efd9a7
2 changed files with 18 additions and 15 deletions
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -2914,26 +2914,29 @@ 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)
|
||||||
if @format
|
result = database.try_persist({}, (options[:credential] || ::GxG::DB[:administrator]))
|
||||||
# merge only keys common to both
|
#
|
||||||
input_object.keys.each do |import_key|
|
if @format
|
||||||
if self.keys.include?(import_key)
|
# merge only keys common to both
|
||||||
|
self.keys.each do |import_key|
|
||||||
|
if input_object.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)]
|
result[(import_key)] = input_object[(import_key)]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result.format = @format
|
#
|
||||||
else
|
|
||||||
input_object.keys.each do |import_key|
|
|
||||||
result[(import_key)] = input_object[(import_key)]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
#
|
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue