Sha256: aced145e76e41c4b7762679b4d98debdcee3d08823221c0be559804762867a6b

Contents?: true

Size: 934 Bytes

Versions: 190

Compression:

Stored size: 934 Bytes

Contents

class Module
  # Declares an attribute reader backed by an internally-named instance variable.
  def attr_internal_reader(*attrs)
    attrs.each do |attr|
      module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
    end
  end

  # Declares an attribute writer backed by an internally-named instance variable.
  def attr_internal_writer(*attrs)
    attrs.each do |attr|
      module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
    end
  end

  # Declares an attribute reader and writer backed by an internally-named instance
  # variable.
  def attr_internal_accessor(*attrs)
    attr_internal_reader(*attrs)
    attr_internal_writer(*attrs)
  end

  alias_method :attr_internal, :attr_internal_accessor

  private
    mattr_accessor :attr_internal_naming_format
    self.attr_internal_naming_format = '@_%s'

    def attr_internal_ivar_name(attr)
      attr_internal_naming_format % attr
    end
end

Version data entries

190 entries across 157 versions & 25 rubygems

Version Path
depengine-0.0.21 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.21 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.20 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.20 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.19 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.19 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.18 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.18 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.17 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.17 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.16 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.15 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.14 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.13 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.13 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.12 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb
depengine-0.0.12 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/attr_internal.rb