Sha256: 057925b9876fbbb60fad3c4e7f93c1cac5574744e1b1882c76436e259ee8419c
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
module Effective class EventsMailer < EffectiveEvents.parent_mailer_class default from: -> { EffectiveEvents.mailer_sender } layout -> { EffectiveEvents.mailer_layout } include EffectiveEmailTemplatesMailer if EffectiveEvents.use_effective_email_templates def event_registrant_purchased(event_registrant, opts = {}) @assigns = assigns_for(event_registrant) @event_registrant = event_registrant mail(to: event_registrant.email, **headers_for(event_registrant, opts)) end protected def headers_for(resource, opts = {}) resource.respond_to?(:log_changes_datatable) ? opts.merge(log: resource) : opts end def assigns_for(resource) if resource.kind_of?(EventRegistrant) return event_registrant_assigns(resource).merge(event_assigns(resource.event)).merge(event_ticket_assigns(resource.event_ticket)) end raise('unexpected resource') end def event_assigns(resource) raise('expected an event') unless resource.kind_of?(Event) values = { name: resource.title, date: resource.start_at.strftime('%F %H:%M'), url: effective_events.event_url(resource) } { event: values } end def event_ticket_assigns(resource) raise('expected an event ticket') unless resource.kind_of?(EventTicket) values = { name: resource.title } { ticket: values } end def event_registrant_assigns(resource) raise('expected an event registrant') unless resource.kind_of?(EventRegistrant) values = { name: resource.name, email: resource.email } { registrant: values } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
effective_events-0.2.6 | app/mailers/effective/events_mailer.rb |