Sha256: 805d2b0388d19421505cf5fdeed101d235a48d47f90c274d3154a00828ec652e

Contents?: true

Size: 796 Bytes

Versions: 85

Compression:

Stored size: 796 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_variable_names.include?(ivar)
                instance_variable_get(ivar)
              end
            else
              instance_variable_set(ivar, parameters.first)
            end
          end
        end
      end
    end
  end
end

Version data entries

85 entries across 82 versions & 16 rubygems

Version Path
actionmailer-2.3.18 lib/action_mailer/adv_attr_accessor.rb
actionmailer_csi-2.3.5.p8 lib/action_mailer/adv_attr_accessor.rb
actionmailer-2.3.17-rack-upgrade-2.3.17 lib/action_mailer/adv_attr_accessor.rb
actionmailer-2.3.17 lib/action_mailer/adv_attr_accessor.rb
actionmailer_csi-2.3.5.p7 lib/action_mailer/adv_attr_accessor.rb
actionmailer_csi-2.3.5.20130130071128 lib/action_mailer/adv_attr_accessor.rb
actionmailer_csi-2.3.5.p6 lib/action_mailer/adv_attr_accessor.rb
actionmailer-2.3.16 lib/action_mailer/adv_attr_accessor.rb
actionmailer-rack-upgrade-2-2.3.16 lib/action_mailer/adv_attr_accessor.rb
actionmailer-rack-upgrade-2-2.3.15 lib/action_mailer/adv_attr_accessor.rb
actionmailer-2.3.15 lib/action_mailer/adv_attr_accessor.rb
actionmailer-rack-upgrade-2.3.17 lib/action_mailer/adv_attr_accessor.rb
actionmailer-rack-upgrade-2.3.16 lib/action_mailer/adv_attr_accessor.rb
actionmailer-rack-upgrade-2.3.15 lib/action_mailer/adv_attr_accessor.rb
actionmailer-rack-upgrade-2.3.14.1 lib/action_mailer/adv_attr_accessor.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/actionmailer-2.3.14/lib/action_mailer/adv_attr_accessor.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/actionmailer-2.3.12/lib/action_mailer/adv_attr_accessor.rb
actionmailer-2.3.14 lib/action_mailer/adv_attr_accessor.rb
kajam-1.0.3.rc2 vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb
actionmailer-2.3.12 lib/action_mailer/adv_attr_accessor.rb