Sha256: 0563333bd0ebf9fcbd56877e03727beae039258963ec7d0d15068531b4f1955d

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

#Model transformation methods
#:include: ../shared/license.rdoc

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

1 entries across 1 versions & 1 rubygems

Version Path
ontomde-core-1.0.2 lib/ontomde-core/clone.rb