2005-05-29 12:36:22 -04:00
|
|
|
module ActionMailer
|
2005-07-06 04:22:56 -04:00
|
|
|
module AdvAttrAccessor #:nodoc:
|
2010-08-29 19:42:09 -04:00
|
|
|
def adv_attr_accessor(name, deprecation=nil)
|
|
|
|
ivar = "@#{name}"
|
|
|
|
deprecation ||= "Please pass :#{name} as hash key to mail() instead"
|
2005-11-21 02:29:33 -05:00
|
|
|
|
2010-08-29 19:42:09 -04:00
|
|
|
class_eval <<-ACCESSORS, __FILE__, __LINE__ + 1
|
|
|
|
def #{name}=(value)
|
|
|
|
ActiveSupport::Deprecation.warn "#{name}= is deprecated. #{deprecation}"
|
|
|
|
#{ivar} = value
|
|
|
|
end
|
2005-05-29 12:36:22 -04:00
|
|
|
|
2010-08-29 19:42:09 -04:00
|
|
|
def #{name}(*args)
|
|
|
|
raise ArgumentError, "expected 0 or 1 parameters" unless args.length <= 1
|
|
|
|
if args.empty?
|
|
|
|
ActiveSupport::Deprecation.warn "#{name}() is deprecated and will be removed in future versions."
|
|
|
|
#{ivar} if instance_variable_names.include?(#{ivar.inspect})
|
|
|
|
else
|
|
|
|
ActiveSupport::Deprecation.warn "#{name}(value) is deprecated. #{deprecation}"
|
|
|
|
#{ivar} = args.first
|
2005-05-29 12:36:22 -04:00
|
|
|
end
|
2010-08-29 19:42:09 -04:00
|
|
|
end
|
|
|
|
ACCESSORS
|
2009-12-25 15:35:40 -05:00
|
|
|
|
2010-08-29 19:42:09 -04:00
|
|
|
self.protected_instance_variables << ivar if self.respond_to?(:protected_instance_variables)
|
2005-05-29 12:36:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|