Class: Decidim::AssemblyMemberPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::AssemblyMemberPresenter
- Defined in:
- decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb
Overview
Decorator for assembly members
Instance Method Summary collapse
- #age ⇒ Object
- #avatar_url(variant = nil) ⇒ Object
- #deleted? ⇒ Boolean
- #has_tooltip? ⇒ Boolean
- #name ⇒ Object
- #nickname ⇒ Object
- #non_user_avatar ⇒ Object
- #non_user_avatar_path(variant = nil) ⇒ Object
- #personal_information ⇒ Object
- #position ⇒ Object
Instance Method Details
#age ⇒ Object
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 |
#avatar_url(variant = nil) ⇒ Object
36 37 38 39 40 |
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 36 def avatar_url(variant = nil) return user.avatar_url(variant) if user.present? non_user_avatar_path(variant) end |
#deleted? ⇒ Boolean
56 57 58 |
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 56 def deleted? false end |
#has_tooltip? ⇒ Boolean
52 53 54 |
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 52 def has_tooltip? false end |
#name ⇒ Object
14 15 16 |
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 14 def name user ? user.name : full_name end |
#nickname ⇒ Object
18 19 20 |
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 18 def nickname user.nickname if user end |
#non_user_avatar ⇒ Object
48 49 50 |
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 48 def non_user_avatar attached_uploader(:non_user_avatar) end |
#non_user_avatar_path(variant = nil) ⇒ Object
42 43 44 45 46 |
# File 'decidim-assemblies/app/presenters/decidim/assembly_member_presenter.rb', line 42 def non_user_avatar_path(variant = nil) return non_user_avatar.default_url(variant) unless non_user_avatar.attached? non_user_avatar.path(variant:) end |
#personal_information ⇒ Object
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 |
#position ⇒ Object
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 |