Sha256: 85c2a334af7bd85037bfad8a02da6542666e238fee6fdd4984eaa41e323e687c

Contents?: true

Size: 905 Bytes

Versions: 97

Compression:

Stored size: 905 Bytes

Contents

class Module
  # Declare 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

  # Declare 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

  # Declare attributes backed by 'internal' instance variables names.
  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

97 entries across 97 versions & 7 rubygems

Version Path
backlog-0.7.12 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.11 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.2 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.3 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.4 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.5 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.6 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.7 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.8 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.7.9 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.8.0 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.8.1 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.9.0 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
backlog-0.9.1 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
radiant-0.6.0 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
radiant-0.6.1 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
radiant-0.6.2 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
radiant-0.6.3 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb
radiant-0.6.4 vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb