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.23.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.22.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.21.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.20.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.20.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.19.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.18.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.19.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.17.2 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.18.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.17.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.16.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.17.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.16.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.15.2 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.15.1 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.15.0 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.14.4 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.14.3 app/presenters/decidim/assembly_member_presenter.rb
decidim-assemblies-0.14.2 app/presenters/decidim/assembly_member_presenter.rb