Module: Card::Set::Type::EmailTemplate
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod013-email/type/email_template.rb
Constant Summary
Constants included from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
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 Card::Set
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore
Methods included from AdvancedApi
#attachment, #ensure_set, #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 Basket
#abstract_basket, #add_to_basket, #basket, #unshift_basket
Methods included from Card::Set::Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
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/mod013-email/type/email_template.rb', line 5 def clean_html? false end |
#deliver(args = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'tmpsets/set/mod013-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/mod013-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/mod013-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/mod013-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 |