Sha256: db60a84dbe2ee9aa2dd562444a7928bace4e7b1c24b5e1bc1ecdc1f225f78ef4

Contents?: true

Size: 949 Bytes

Versions: 48

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

module Decidim
  #
  # Decorator for assembly members
  #
  class AssemblyMemberPresenter < SimpleDelegator
    def age
      (Time.current.strftime("%Y%m%d").to_i - birthday.strftime("%Y%m%d").to_i) / 10_000 if birthday
    end

    delegate :profile_url, :avatar_url, to: :user, allow_nil: true

    def name
      user ? user.name : full_name
    end

    def nickname
      user.nickname if user
    end

    def personal_information
      [
        gender.presence,
        age,
        birthplace.presence
      ].compact.join(" / ")
    end

    def position
      return position_other if __getobj__.position == "other"

      I18n.t(__getobj__.position, scope: "decidim.admin.models.assembly_member.positions", default: "")
    end

    private

    def user
      @user ||= begin
        if (user = __getobj__.user.presence)
          Decidim::UserPresenter.new(user)
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
decidim-assemblies-0.25.2 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.25.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.25.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.25.0.rc4 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.25.0.rc3 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.25.0.rc2 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.25.0.rc1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.24.3 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.23.6 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.24.2 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.23.5 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.24.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.24.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.24.0.rc2 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.23.4 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.24.0.rc1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.23.3 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.23.2 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.23.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.23.1.rc1 app/presenters/decidim/assembly_member_presenter.rb