class MandrillQueue::Message::Recipient::Variable
Attributes
var_name[R]
Public Class Methods
new(recipient = nil, *args, &block)
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 14 def initialize(recipient = nil, *args, &block) @_recipient = recipient dsl(&block) if block_given? end
variables(name)
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 8 def variables(name) @var_name = name Variables::DSL.include_as(self, name) end
Public Instance Methods
dsl(&block)
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 60 def dsl(&block) send(var_name).dsl(&block) end
recipient(value = nil)
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 27 def recipient(value = nil) @_recipient = value unless value.nil? @_recipient end
recipient=(value)
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 23 def recipient=(value) @_recipient = value end
set!(hash)
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 53 def set!(hash) @_recipient = hash[:rcpt] var_instance_set(nil) send(var_name).set!(hash[var_name]) unless hash[var_name].nil? self end
to_hash(options = {})
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 44 def to_hash(options = {}) hash = {} hash[:rcpt] = recipient if options[:include_nils] || !recipient.nil? if options[:include_nils] || var_instance hash[var_name] = send(var_name).to_key_value_array(options) end hash end
validate(errors, options = {})
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 64 def validate(errors, options = {}) cn = options[:as] || self.class.name.underscore.split('/').last.to_sym errors.push([cn, "Recipient cannot be empty."]) if recipient.blank? end
var_instance()
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 32 def var_instance instance_variable_get("@_#{var_name}".to_sym) end
var_instance_set(value)
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 40 def var_instance_set(value) instance_variable_set("@_#{var_name}".to_sym, value) end
var_name()
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 19 def var_name self.class.var_name end
variables()
click to toggle source
# File lib/mandrill_queue/message/recipient/variable.rb, line 36 def variables send(var_name) end