Sha256: bf372a22f495397896d174f0296f711d107cf448a83d582edac8c04978fc0311

Contents?: true

Size: 788 Bytes

Versions: 5

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

require "hanami/view"

module Milestoner
  module Views
    module Parts
      # The user presentation logic.
      class User < Hanami::View::Part
        include Import[:settings]

        def name = value.name.then { |text| text || "Unknown" }

        def image_alt = value.name.then { |name| name || "missing" }

        def avatar_url
          value.name.then do |name|
            return format settings.avatar_uri, id: value.external_id if name

            "https://alchemists.io/images/projects/milestoner/icons/missing.png"
          end
        end

        def profile_url
          value.name.then do |name|
            name ? format(settings.profile_uri, id: value.handle) : "/#unknown"
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
milestoner-18.11.0 lib/milestoner/views/parts/user.rb
milestoner-18.10.0 lib/milestoner/views/parts/user.rb
milestoner-18.9.0 lib/milestoner/views/parts/user.rb
milestoner-18.8.0 lib/milestoner/views/parts/user.rb
milestoner-18.7.0 lib/milestoner/views/parts/user.rb