Sha256: 4ce6a4599b61199b27842947460b4624a9a0d727453c62cd0a237e7765debca0

Contents?: true

Size: 791 Bytes

Versions: 91

Compression:

Stored size: 791 Bytes

Contents

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

    module ClassMethods #:nodoc:
      def adv_attr_accessor(*names)
        names.each do |name|
          ivar = "@#{name}"

          define_method("#{name}=") do |value|
            instance_variable_set(ivar, value)
          end

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

Version data entries

91 entries across 91 versions & 6 rubygems

Version Path
backlog-0.4.0 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.0 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.1 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.2 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.10 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.3 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.4 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.5 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.6 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.7 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.8 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.5.9 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.6.0 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.6.1 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.6.2 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.6.5 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.6.3 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.6.4 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.7.0 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
backlog-0.6.6 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb