Class: MergeAttribute
Instance Method Summary collapse
- #check_changes(from_attribute) ⇒ Object
- #check_existing_attribute(from_attribute, to_attribute) ⇒ Object
- #check_removed ⇒ Object
-
#initialize(from_class, to_class) ⇒ MergeAttribute
constructor
A new instance of MergeAttribute.
- #new_attribute(from_attribute) ⇒ Object
- #verify ⇒ Object
Methods inherited from Merge
#check, #check_change_propertie, #merge
Constructor Details
#initialize(from_class, to_class) ⇒ MergeAttribute
Returns a new instance of MergeAttribute.
9 10 11 12 13 |
# File 'lib/xmimerge/merge_attributes.rb', line 9 def initialize(from_class, to_class) super() @from_class = from_class @to_class = to_class end |
Instance Method Details
#check_changes(from_attribute) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/xmimerge/merge_attributes.rb', line 28 def check_changes(from_attribute) @log.debug("Checking attribute: #{@from_class.full_name}::#{from_attribute.name}") if @only_check # Localiza o atributo no modelo destino pelo nome to_attribute = @to_class.attribute_by_name(from_attribute.name) if to_attribute.nil? # Se não encontrou é poque é um novo atributo new_attribute from_attribute else # Atributo já existe, verifica se houve alterações check_existing_attribute(from_attribute, to_attribute) end end |
#check_existing_attribute(from_attribute, to_attribute) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/xmimerge/merge_attributes.rb', line 84 def check_existing_attribute(from_attribute, to_attribute) from_full_attribute_name = "#{@from_class.full_name}::#{from_attribute.name}" # Name #changes = Util.check_change_by_method("name", from_attribute, to_attribute) #check_change_propertie(changes, "AttributeName", from_attribute.full_name) # Visibility check_change_propertie("visibility", from_attribute, to_attribute, "AttributeVisibility") # Type check_change_propertie("type", from_attribute, to_attribute, "AttributeType") # Initial Value check_change_propertie("initial_value", from_attribute, to_attribute, "AttributeInitialValue") # Multiplicity merge = MergeMultiplicity.new("Attribute", from_attribute, to_attribute) @only_check ? merge.check : merge.merge # Stereotypes merge = MergeStereotypes.new("Attribute", from_attribute, to_attribute) @only_check ? merge.check : merge.merge # TaggedValues t = MergeTaggedValues.new("Attribute", from_attribute, to_attribute) @only_check ? t.check : t.merge # TODO # Type Modifier # Changeability # Ordering # Scope # Documentation end |
#check_removed ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/xmimerge/merge_attributes.rb', line 43 def check_removed @to_class.attributes.each do |to_attribute| ok = false @from_class.attributes.each do |from_attribute| if from_attribute.name == to_attribute.name ok = true break end end if !ok command = "\t- Attribute #{@from_class.full_name}::#{to_attribute.name}" @commands.add_command_to_buffer(command) unless @only_check if @commands.has_command?(command) @log.info "[OK] #{command}" else #@log.warn "[NOT] #{command}" end end end end end |
#new_attribute(from_attribute) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/xmimerge/merge_attributes.rb', line 68 def new_attribute(from_attribute) @log.debug("New Attribute") if @only_check command = "\t+ Attribute #{@from_class.full_name}::#{from_attribute.name}" @commands.add_command_to_buffer(command) unless @only_check if @commands.has_command?(command) @to_class.add_xml_attribute(from_attribute.xml.to_xml) @log.info "[OK] #{command}" else #@log.warn "[NOT] #{command}" end end end |
#verify ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/xmimerge/merge_attributes.rb', line 15 def verify initial_buffer_size = @commands.buffer_size @from_class.attributes.each do |from_attribute| check_changes(from_attribute) end check_removed @commands.buffer_size != initial_buffer_size end |