Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use if/elsif instead of ||= with guard clause #3975

Merged
merged 1 commit into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/models/concerns/master_file_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ def hls_streams
end

def display_title
mf_title = structuralMetadata.section_title if has_structuralMetadata?
mf_title ||= title if title.present?
mf_title ||= file_location.split("/").last if file_location.present? && (media_object.master_file_ids.size > 1)
mf_title = if has_structuralMetadata?
structuralMetadata.section_title
elsif title.present?
title
# FIXME: The test for media_object.master_file_ids.size is expensive and takes ~0.25 seconds
elsif file_location.present? && (media_object.master_file_ids.size > 1)
file_location.split("/").last
end
mf_title.blank? ? nil : mf_title
end

Expand Down
11 changes: 8 additions & 3 deletions app/presenters/speedy_af/proxy/master_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ def find_encoder_class(klass_name)
end

def display_title
mf_title = structuralMetadata.section_title if has_structuralMetadata?
mf_title ||= title if title.present?
mf_title ||= file_location.split("/").last if file_location.present? && (media_object.master_file_ids.size > 1)
mf_title = if has_structuralMetadata?
structuralMetadata.section_title
elsif title.present?
title
# FIXME: The test for media_object.master_file_ids.size is expensive and takes ~0.25 seconds
elsif file_location.present? && (media_object.master_file_ids.size > 1)
file_location.split("/").last
end
mf_title.blank? ? nil : mf_title
end
end