Sha256: 0f72721c4c49afbfd944e697072efcf3b5e0a93c40b968f4ff16779fea6c85f5

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

#

class String
  # Clones a string
  # return self by default.(String are not cloned)
  def rdfx_clone
    return self
  end
end

module Mrdf_Resource
  # Clones a uml resource.
  # Referenced objects are cloned if rdfx_copyOnClone says so.
  def rdfx_clone
    c=self.clone
    c.rdf_uri="_transient_#{c.object_id}"
    c.rdf_model[c.rdf_uri]=c

    instance_variables.each { |v|
      ivg=instance_variable_get(v)
      next if (!ivg.kind_of?(ArrayOrSingleElement)) ||
        (!isResetable?(v)) ||
        (!rdfx_copyOnClone?(v))

      newVal=createEmptyAttributeValue
      #puts "clone v=#{v}"
      self.instance_variable_get(v).each { | res|
        newVal.push(res.rdfx_clone)
        c.instance_variable_set(v,newVal)
      }
    }
    return c
  end

  # Returns true if object should be copied on clone for this property.
  # NOTE:
  #   returns true if property name contains "_owned". (works for UML)
  def rdfx_copyOnClone?(prop)
    return prop.include?('_owned')
    #copyOrClone=copyOnCloneProperties[prop]
    #if copyOrClone.nil?
    #puts "WARNING: unspecified copy on clone for #{prop} on #{self.class.name}"
    #end
    #return copyOrClone
  end
end
#module Mrdf_Resource
#	#CopyOnCloneProperties={ }
#	def copyOnCloneProperties
#		#CopyOnCloneProperties
#	end
#end
#module Muml_Class
#	CopyOnCloneProperties={ '@uml_packageableElement_packageableElement_visibility' => true,
#		'@uml_structuredClassifier_ownedAttribute' => true,
#		'@mtk_rubyClassGenerated' => true,
#		'@uml_classifier_generalization' => true,
#		'@uml_namedElement_visibility' => true,
#		'@uml_namedElement_clientDependency' => true,
#		'@umlx_packageableElement_owner' => true,
#		'@ext_isReferencedBy' => true,
#		'@uml_class_ownedOperation' => true,
#		'@uml_behavioredClassifier_implementation' => true,
#		'@uml_namedElement_name' => true }
#	#def copyOnCloneProperties
#	#	CopyOnCloneProperties #_class
#	#end
#end




Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ontomde-core-1.0.4 lib/ontomde-core/clone.rb
ontomde-core-1.0.6 lib/ontomde-core/clone.rb