Class: Tramway::Event::Events::Show::EventDecorator
- Inherits:
-
Core::ApplicationDecorator
- Object
- Core::ApplicationDecorator
- Tramway::Event::Events::Show::EventDecorator
- Defined in:
- app/decorators/tramway/event/events/show/event_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #background ⇒ Object
- #duration ⇒ Object (also: #tagline)
- #partners ⇒ Object
- #responsible_person ⇒ Object
Class Method Details
.collections ⇒ Object
5 6 7 |
# File 'app/decorators/tramway/event/events/show/event_decorator.rb', line 5 def collections [:all] end |
Instance Method Details
#background ⇒ Object
23 24 25 |
# File 'app/decorators/tramway/event/events/show/event_decorator.rb', line 23 def background object.photo end |
#duration ⇒ Object Also known as: tagline
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/decorators/tramway/event/events/show/event_decorator.rb', line 27 def duration return unless object.begin_date.present? || object.end_date.present? if object.begin_date.to_date == object.end_date.to_date I18n.l(object.begin_date, format: '%d %B %Y').to_s elsif object.begin_date.month == object.end_date.month "#{I18n.t('date.from')} #{I18n.l(object.begin_date, format: '%d')} #{I18n.t('date.to')} #{I18n.l(object.end_date, format: '%d %B %Y')}" else "#{I18n.t('date.from')} #{I18n.l(object.begin_date, format: '%d %B %Y')} #{I18n.t('date.to')} #{I18n.l(object.end_date, format: '%d %B %Y')}" end end |
#partners ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/decorators/tramway/event/events/show/event_decorator.rb', line 39 def partners if defined?(::Tramway::Partner) @partners ||= ::Tramway::Partner::Partnership.partnership_type.values.reduce({}) do |hash, partnership_type| hash.merge! partnership_type => (object.send(partnership_type.to_s.pluralize).active.map do |partner| Tramway::Partner::OrganizationFeatureDecorator.decorate partner end) end end end |
#responsible_person ⇒ Object
51 52 53 54 55 56 |
# File 'app/decorators/tramway/event/events/show/event_decorator.rb', line 51 def responsible_person { phone: (object.creator.phone if object.creator&.phone&.present?), email: (object.creator.email if object.creator&.email&.present?) } end |