Skip to content

Commit

Permalink
obey rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
as-op committed Sep 2, 2024
1 parent 59f8218 commit e9fa439
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/open_project/text_formatting/matchers/attribute_macros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ def self.relative_embed?(macro_attributes)
macro_attributes[:id].nil?
end

def self.relative_id(macro_attributes, context)
if project_embed?(macro_attributes) && context[:project].present?
context[:project].try(:id)
elsif work_package_embed?(macro_attributes) && work_package_context?(context)
context[:object].try(:id)
end
end

def self.process_match(match, _matched_string, context)
# Leading string before match
macro_attributes = {
Expand All @@ -79,13 +87,7 @@ def self.process_match(match, _matched_string, context)
}
type = match[2].downcase

if relative_embed?(macro_attributes)
if project_embed?(macro_attributes) && context[:project].present?
macro_attributes[:id] = context[:project].try(:id)
elsif work_package_embed?(macro_attributes) && work_package_context?(context)
macro_attributes[:id] = context[:object].try(:id)
end
end
macro_attributes[:id] = relative_id(macro_attributes, context) if relative_embed?(macro_attributes)

ApplicationController.helpers.content_tag "opce-macro-attribute-#{type}",
"",
Expand Down

0 comments on commit e9fa439

Please sign in to comment.