Skip to content

Simplify helper methods by using Repository::Owner consistently#97

Merged
tricknotes merged 2 commits intoclaude/xenodochial-engelbartfrom
claude/sub-pr-96
Mar 24, 2026
Merged

Simplify helper methods by using Repository::Owner consistently#97
tricknotes merged 2 commits intoclaude/xenodochial-engelbartfrom
claude/sub-pr-96

Conversation

@Claude
Copy link
Copy Markdown

@Claude Claude AI commented Mar 24, 2026

Addresses feedback on #96 to simplify the helper methods in application_helper.rb that were handling multiple data type variations (User models, Data objects, and hashes) with complex conditional branching.

Changes

  • image_link_to_github_url: Reduced multi-branch conditional to simple ternary operator
  • avatar_image_tag: Eliminated middle respond_to?(:login) branch, now handles only User vs. owner objects
  • image_link_to_github_url_from_event: Creates Repository::Owner Data object instead of passing hash

Result

Before:

def image_link_to_github_url(user, size = '30x30')
  username = if user.is_a?(User)
    user.username
  elsif user.respond_to?(:login)
    user.login
  else
    user['login']
  end
  link_to avatar_image_tag(user, size), github_url(username)
end

After:

def image_link_to_github_url(user, size = '30x30')
  username = user.is_a?(User) ? user.username : user.login
  link_to avatar_image_tag(user, size), github_url(username)
end

Type consistency enforced: all owner data now uses Repository::Owner Data objects with .login and .avatar_url methods.

@Claude Claude AI changed the title [WIP] [WIP] Address feedback by simplifying MongoDB-to-GitHub API integration Simplify helper methods by using Repository::Owner consistently Mar 24, 2026
@Claude Claude AI requested a review from tricknotes March 24, 2026 14:59
@tricknotes tricknotes marked this pull request as ready for review March 24, 2026 15:07
@tricknotes tricknotes merged commit e90d9b3 into claude/xenodochial-engelbart Mar 24, 2026
3 checks passed
@tricknotes tricknotes deleted the claude/sub-pr-96 branch March 24, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants