Sha256: f10093d07aeff944bee9da2cd7e2a98a1120544f37cac69e88eb987649f5836e
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Macaco class Sender def initialize(*args, &block) @body_html = nil @body_text = nil @text = nil @to = [] @from = nil @subject = nil if args.first.is_a? Hash hash_attributes(args.first) end if block_given? instance_eval(&block) end self end def hash_attributes(args) to args[:to] from args[:from] subject args[:subject] body_html args[:body_html] body_text args[:body_text] end def to(val = nil) return @to unless val @to << val end def from(val = nil) return @from unless val @from ||= val end def subject(val = nil) return @subject unless val @subject ||= val end def body_html(val = nil) return @body_html unless val @body_html ||= val end alias_method :html, :body_html def body_text(val = nil) return @body_text unless val @body_text ||= val end alias_method :text, :body_text # helpers - could be split out? def to_json to_hash.to_json end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
macaco-0.0.6 | lib/macaco/senders/sender.rb |
macaco-0.0.5 | lib/macaco/senders/sender.rb |