Class: Ticket::Replicator::RowLoader
- Inherits:
-
Object
- Object
- Ticket::Replicator::RowLoader
show all
- Defined in:
- lib/ticket/replicator/row_loader.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(jira_project, row) ⇒ RowLoader
23
24
25
26
|
# File 'lib/ticket/replicator/row_loader.rb', line 23
def initialize(jira_project, row)
@jira_project = jira_project
@row = row
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
175
176
177
178
179
180
181
|
# File 'lib/ticket/replicator/row_loader.rb', line 175
def method_missing(name, *args)
if field_to_load?(name)
row.fetch(name) { |key| raise "No value found for #{key.inspect} in #{row.inspect}" }
else
super
end
end
|
Instance Attribute Details
#jira_project ⇒ Object
Returns the value of attribute jira_project.
21
22
23
|
# File 'lib/ticket/replicator/row_loader.rb', line 21
def jira_project
@jira_project
end
|
#row ⇒ Object
Returns the value of attribute row.
21
22
23
|
# File 'lib/ticket/replicator/row_loader.rb', line 21
def row
@row
end
|
Class Method Details
.build_ticket_link_attributes(url, title, application_name = Ticket::SOURCE_TICKET_REMOTE_LINK_APPLICATION) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/ticket/replicator/row_loader.rb', line 12
def self.build_ticket_link_attributes(
url, title, application_name = Ticket::SOURCE_TICKET_REMOTE_LINK_APPLICATION
)
{ "object" => { "url" => url, "title" => title } }
.merge(application_name ? { "application" => { "name" => application_name } } : {})
end
|
.fields_to_load ⇒ Object
196
197
198
199
|
# File 'lib/ticket/replicator/row_loader.rb', line 196
def fields_to_load
@fields_to_load ||=
RowTransformer.fields_to_transform.collect { |field| field.to_s.parameterize.underscore.to_sym }
end
|
.run_on(jira_project, row) ⇒ Object
8
9
10
|
# File 'lib/ticket/replicator/row_loader.rb', line 8
def self.run_on(jira_project, row)
new(jira_project, row).run
end
|
Instance Method Details
#run ⇒ Object
28
29
30
31
32
|
# File 'lib/ticket/replicator/row_loader.rb', line 28
def run
save_ticket
update_source_ticket_remote_link
transition_ticket_to_the_expected_status
end
|
#save_ticket ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/ticket/replicator/row_loader.rb', line 38
def save_ticket
return unless ticket_fields_need_to_be_updated?
reopen_ticket_if_status_in_done_category
ticket.jira_ticket.save!(attributes_for_save)
ticket.jira_ticket.fetch
@ticket_was_just_updated = true
jira_project.replicated_tickets[id] = ticket
end
|
#ticket_previously_replicated? ⇒ Boolean
34
35
36
|
# File 'lib/ticket/replicator/row_loader.rb', line 34
def ticket_previously_replicated?
jira_project.replicated_tickets.key?(id)
end
|