Module: Card::Set::Type::EmailTemplate::EmailConfig

Extended by:
Card::Set
Defined in:
platypus/tmp/set/gem-defaults/mod012-email/type/email_template/email_config.rb

Overview

Set: All “EmailTemplate+EmailConfig” cards (EmailConfig)

Constant Summary collapse

EMAIL_FIELDS =
%i[to from cc bcc attach subject text_message html_message].freeze
EMAIL_FIELD_METHODS =
{ subject: :contextual_content,
text_message: :contextual_content,
attach: :recursed_item_contents }.freeze

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset

Methods included from I18nScope

#mod_name, #scope

Methods included from Registrar

#extended, #finalize_load, #process_base_modules, #register_set

Methods included from Helpers

#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name

Methods included from AdvancedApi

#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Card::Set::Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'platypus/tmp/set/gem-defaults/mod012-email/type/email_template/email_config.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/mod/email/set/type/email_template/email_config.rb"; end

Instance Method Details

#email_config(context, fields = {}, opts = {}) ⇒ Object

Parameters:

  • context (Card)

    the card in whose context all email fields will be interpreted

  • fields (Hash) (defaults to: {})

    override any templated field configurations with hash values

  • opts (Hash) (defaults to: {})

    options for rendering. unknown options become format options

Options Hash (opts):

  • :auth (Card, String, Integer)

    user identifier. render as this user



20
21
22
23
24
25
26
27
28
# File 'platypus/tmp/set/gem-defaults/mod012-email/type/email_template/email_config.rb', line 20

def email_config context, fields={}, opts={}
  @active_email_context = context || self
  auth = opts.delete :auth
  config = EMAIL_FIELDS.each_with_object({}) do |field, conf|
    conf[field] = fields[field] || email_field_from_card(field, auth, opts)
  end
  safe_from_and_reply_to! config
  config.select { |_k, v| v.present? }
end

#email_html_message_field(message_card, auth, format_opts) ⇒ Object

html messages return procs because image attachments can’t be properly rendered without a mail object. (which isn’t available at initial config time)



32
33
34
35
36
37
38
39
# File 'platypus/tmp/set/gem-defaults/mod012-email/type/email_template/email_config.rb', line 32

def email_html_message_field message_card, auth, format_opts
  proc do |mail|
    Auth.as auth do
      format_opts = format_opts.merge format: :email_html, active_mail: mail
      message_card.format(format_opts).email_content @active_email_context
    end
  end
end