Class: Decidim::AssemblyMemberPresenter

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb

Overview

Decorator for assembly members

Instance Method Summary collapse

Instance Method Details

#ageObject


8
9
10
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 8

def age
  (Time.current.strftime("%Y%m%d").to_i - birthday.strftime("%Y%m%d").to_i) / 10_000 if birthday
end

#nameObject


14
15
16
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 14

def name
  user ? user.name : full_name
end

#nicknameObject


18
19
20
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 18

def nickname
  user.nickname if user
end

#personal_informationObject


22
23
24
25
26
27
28
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 22

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

#positionObject


30
31
32
33
34
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 30

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

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