class MandrillQueue::ArrayMetadata::Var

Public Class Methods

new(recipient = nil, &block) click to toggle source
# File lib/mandrill_queue/array_metadata.rb, line 6
def initialize(recipient = nil, &block)
        @_recipient = recipient
        dsl(&block) if block_given?
end

Public Instance Methods

dsl(&block) click to toggle source
# File lib/mandrill_queue/array_metadata.rb, line 34
def dsl(&block)
        vars.dsl(&block)
end
recipient(value = nil) click to toggle source
# File lib/mandrill_queue/array_metadata.rb, line 15
def recipient(value = nil)
        @_recipient = value unless value.nil?
        @_recipient
end
recipient=(value) click to toggle source
# File lib/mandrill_queue/array_metadata.rb, line 11
def recipient=(value)
        @_recipient = value
end
set!(hash) click to toggle source
# File lib/mandrill_queue/array_metadata.rb, line 27
def set!(hash)
        @_recipient = hash[:rcpt]
        @_vars = nil
        vars.set!(hash[:vars]) unless hash[:vars].nil?
        self
end
to_hash(options = {}) click to toggle source
# File lib/mandrill_queue/array_metadata.rb, line 20
def to_hash(options = {})
        hash = {}
        hash[:rcpt] = recipient if options[:include_nils] || !recipient.nil?
        hash[:vars] = vars.to_key_value_array(options) if options[:include_nils] || !@_vars.nil?
        hash
end
validate(errors) click to toggle source
# File lib/mandrill_queue/array_metadata.rb, line 38
def validate(errors)
        errors.push([:merge_vars, "Recipient cannot be empty for merge vars."]) if recipient.blank?
end