Module: Card::Set::Type::EmailTemplate
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod006-05_email/type/email_template.rb
Instance Method Summary collapse
-
#clean_html? ⇒ Boolean
~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_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
abstract_set?, all_set?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_on_format, ensure_set, extended, format, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, stage_method, view, write_tmp_file
Methods included from Event
Instance Method Details
#clean_html? ⇒ Boolean
~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_email/set/type/email_template.rb ~~~~~~~~~~~
5 6 7 |
# File 'tmpsets/set/mod006-05_email/type/email_template.rb', line 5 def clean_html? false end |
#deliver(args = {}) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'tmpsets/set/mod006-05_email/type/email_template.rb', line 9 def deliver args={} begin mail = format.render_mail(args) mail.deliver rescue Net::SMTPError => exception errors.add :exception, exception. end 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 |
# File 'tmpsets/set/mod006-05_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: :inclusion_only } :text_message, config, args, 'email_text' :html_message, config, args, 'email_html' config[:html_message] = Card::Mailer.layout config[:html_message] if config[:html_message].present? from_name, from_email = (config[:from] =~ /(.*)\<(.*)>/) ? [$1.strip, $2] : [nil, config[:from]] if default_from=Card::Mailer.default[:from] config[:from] = from_email ? %["#{from_name || from_email}" <#{default_from}>] : default_from 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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'tmpsets/set/mod006-05_email/type/email_template.rb', line 18 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] and 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
33 34 35 36 37 38 39 |
# File 'tmpsets/set/mod006-05_email/type/email_template.rb', line 33 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 |