Class: RequirementCopy

Inherits:
ObjectCopy show all
Defined in:
lib/translate/copy/requirement_copy.rb

Instance Method Summary collapse

Methods inherited from ObjectCopy

#card_values, #copy, #copy_children, #excluded_attributes, #fetch_object, #fetch_project, #find_project_in_new_workspace, #initialize, #logger, #new_workspace, #rally_rest, #remember, #shallow_copy, #tangle, #user_exists?

Constructor Details

This class inherits a constructor from ObjectCopy

Instance Method Details

#create_object(values) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/translate/copy/requirement_copy.rb', line 3

def create_object(values)
  new_object = rally_rest.create(:hierarchical_requirement, values)

  if @object.cards
    @object.cards.each do |card|
card.copy(new_workspace, :parent => new_object)
    end
  end

  if @object.dependents
    @object.dependents.each do |dependent|
	if dependent_in_correct_project? dependent
 dependent.copy(new_workspace, :parent => new_object)
	else
 logger.warn "For '#{@object.type}' with name '#{@object.name}' in project '#{project_name @object.project}' not creating child association to dependent of type '#{dependent.type}' with name '#{dependent.name}' in project '#{project_name dependent.project}' because dependent it is in the wrong project."
	end
    end
  end

  new_object
end

#dependent_in_correct_project?(dependent) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/translate/copy/requirement_copy.rb', line 30

def dependent_in_correct_project?(dependent)
  (in_same_project?(dependent) || in_child_project?(dependent)) && !in_different_child_projects?(dependent)
end

#in_child_project?(dependent) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/translate/copy/requirement_copy.rb', line 38

def in_child_project?(dependent)
  @object.in_parent_project? && !dependent.in_parent_project?
end

#in_different_child_projects?(dependent) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/translate/copy/requirement_copy.rb', line 42

def in_different_child_projects?(dependent)
  !@object.in_parent_project? && !dependent.in_parent_project? && !in_same_project?(dependent)
end

#in_same_project?(dependent) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/translate/copy/requirement_copy.rb', line 34

def in_same_project?(dependent)
  @object.project == dependent.project
end

#project_name(project) ⇒ Object



25
26
27
28
# File 'lib/translate/copy/requirement_copy.rb', line 25

def project_name(project)
  return "Parent Project" if project.nil?
  project.name
end

#type_as_symbolObject



46
47
48
# File 'lib/translate/copy/requirement_copy.rb', line 46

def type_as_symbol
  :hierarchical_requirement
end