Sha256: c4a499dd847dc57f8781e9174747c7b846c94cd54a268a6961a4cc7f06463466

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

module Rad
  class Letter
    inject mailer: :mailer
    
    attr_accessor :from, :to, :subject, :body
    
    def initialize properties
      properties.each do |k, v|
        send "#{k}=", v
      end
    end
    
    def validate!
      from || raise("letter :from not specified!")
      to || raise("letter :to not specified!")
      subject || raise("letter :subject not specified!")
      body || raise("letter :body not specified!") 
    end
    
    def deliver
      validate!
      mailer.deliver self
    end
    
    def to_hash
      {from: from, to: to, subject: subject, body: body}
    end
    alias_method :to_h, :to_hash
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rad_core-0.0.13 lib/rad/mail/letter.rb