class MandrillQueue::Message::Recipients::Recipient

Constants

ACCESSORS

Public Class Methods

new(email = nil, name = nil, type = nil, &block) click to toggle source
# File lib/mandrill_queue/message/recipients.rb, line 32
def initialize(email = nil, name = nil, type = nil, &block)
        @type = type
        @name = name
        @email = email

        instance_eval(&block) if block_given?
end

Public Instance Methods

set!(hash) click to toggle source
# File lib/mandrill_queue/message/recipients.rb, line 52
def set!(hash)
        ACCESSORS.each do |key|
                instance_variable_set("@#{key}".to_sym, hash[key])
        end

        self
end
to_hash(options = {}) click to toggle source
# File lib/mandrill_queue/message/recipients.rb, line 60
def to_hash(options = {})
        hash = {}
        ACCESSORS.each do |key|
                value = send(key)
                if options[:include_nils] || !value.nil?
                        hash[key] = value.nil? ? nil : value.to_s
                end
        end
        hash
end
validate(errors) click to toggle source
# File lib/mandrill_queue/message/recipients.rb, line 71
def validate(errors)
        errors.push([@type, "Email must be set for recipient."]) if email.nil?
end