Module: Card::Set::Type::EmailTemplate
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod012-email/type/email_template.rb
Instance Method Summary collapse
-
#clean_html? ⇒ Boolean
~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/email/set/type/email_template.rb ~~.
- #deliver(args = {}) ⇒ Object
- #email_config(args = {}) ⇒ Object
- #process_email_field(field, config, args) ⇒ Object
- #process_message_field(field, config, args, format, special_args = nil) ⇒ Object
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #pattern_and_modules_from_path, #process_base_modules, #register_set, #tmp_file_frame, #tmp_file_template, #tmp_file_wrapped_content, #write_tmp_file
Methods included from Helpers
#abstract_set?, #all_set?, #shortname
Methods included from AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#all_set_format_mod!, #define_on_format, #format, #register_set_format, #view
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket
Methods included from Card::Set::Trait
#card_accessor, #card_reader, #card_writer
Methods included from Event
Instance Method Details
#clean_html? ⇒ Boolean
~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/email/set/type/email_template.rb ~~
5 6 7 |
# File 'tmpsets/set/mod012-email/type/email_template.rb', line 5 def clean_html? false end |
#deliver(args = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'tmpsets/set/mod012-email/type/email_template.rb', line 9 def deliver args={} mail = format.render_mail(args) mail.deliver rescue Net::SMTPError => exception errors.add :exception, exception. end |
#email_config(args = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'tmpsets/set/mod012-email/type/email_template.rb', line 41 def email_config args={} config = {} args[:context] ||= self [:to, :from, :cc, :bcc].each do |field_name| process_email_field(field_name, config, args) do |field_card| field_card.process_email_addresses( args[:context], { format: "email_text" }, args ) end end process_email_field(:attach, config, args) do |field_card| field_card.extended_item_contents args[:context] end :subject, config, args, "email_text", content_opts: { chunk_list: :nest_only } :text_message, config, args, "email_text" :html_message, config, args, "email_html" if config[:html_message].present? config[:html_message] = Card::Mailer.layout config[:html_message] end from_name, from_email = if config[:from] =~ /(.*)\<(.*)>/ [Regexp.last_match(1).strip, Regexp.last_match(2)] else [nil, config[:from]] end if (default_from = Card::Mailer.default[:from]) config[:from] = if from_email %("#{from_name || from_email}" <#{default_from}>) else default_from end config[:reply_to] ||= config[:from] elsif config[:from].blank? config[:from] = Card[Card::WagnBotID].account.email end config.select { |_k, v| v.present? } end |
#process_email_field(field, config, args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'tmpsets/set/mod012-email/type/email_template.rb', line 16 def process_email_field field, config, args config[field] = if args[field] args[field] elsif (field_card = fetch(trait: field)) # configuration can be anything visible to configurer user = (args[:follower] && Card.fetch(args[:follower])) || field_card.updater Auth.as(user) do yield(field_card) end else "" end end |
#process_message_field(field, config, args, format, special_args = nil) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'tmpsets/set/mod012-email/type/email_template.rb', line 32 def field, config, args, format, special_args=nil process_email_field(field, config, args) do |field_card| content_args = args.clone content_args.merge! special_args if special_args field_card.contextual_content args[:context], { format: format }, content_args end end |