education/classroom

View on GitHub
app/view_models/roster_entry/show_view.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class RosterEntry
  class ShowView < ViewModel
    attr_reader :roster_entry

    delegate :identifier, to: :roster_entry

    def linked?
      roster_entry.user.present?
    end

    def github_handle_text
      linked? ? "@" + roster_entry.user.github_user.login : "Not linked"
    end

    def github_profile_url
      roster_entry.user.github_user.html_url
    end

    def github_avatar_url
      roster_entry.user.github_user.github_avatar_url(96)
    end

    def button_text
      linked? ? "Unlink GitHub account" : "Link GitHub account"
    end

    def button_class
      linked? ? "btn btn-danger" : "btn btn-outline"
    end
  end
end