Skip to content
This repository
tree: 2789b5d2ce
Fetching contributors…

Cannot retrieve contributors at this time

file 56 lines (50 sloc) 1.458 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
module ActionMailer
  module AdvAttrAccessor #:nodoc:
    def self.append_features(base)
      super
      base.extend(ClassMethods)
    end

    module ClassMethods #:nodoc:
      def adv_attr_accessor(*names)
        names.each do |name|
          define_method("#{name}=") do |value|
            instance_variable_set("@#{name}", value)
          end

          define_method(name) do |*parameters|
            raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1
            if parameters.empty?
              instance_variable_get("@#{name}")
            else
              instance_variable_set("@#{name}", parameters.first)
            end
          end
        end
      end
    end
  end
end

module ActionMailer
  module AdvAttrAccessor #:nodoc:
    def self.append_features(base)
      super
      base.extend(ClassMethods)
    end

    module ClassMethods #:nodoc:
      def adv_attr_accessor(*names)
        names.each do |name|
          define_method("#{name}=") do |value|
            instance_variable_set("@#{name}", value)
          end

          define_method(name) do |*parameters|
            raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1
            if parameters.empty?
              instance_variable_get("@#{name}")
            else
              instance_variable_set("@#{name}", parameters.first)
            end
          end
        end
      end

    end
  end
end
Something went wrong with that request. Please try again.