Sha256: e6d07c4fe5a81e7f979592b670c8b081886b9905323d314904c8512a8d4d13ca

Contents?: true

Size: 857 Bytes

Versions: 20

Compression:

Stored size: 857 Bytes

Contents

class Module

  private

  # As with alias_method, but alias both reader and writer.
  #
  #   attr_accessor :x
  #   self.x = 1
  #   alias_accessor :y, :x
  #   y #=> 1
  #   self.y = 2
  #   x #=> 2
  #
  def alias_accessor(*args)
    orig = args.last
    args = args - [orig]
    args.each do |name|
      alias_method(name, orig)
      alias_method("#{name}=", "#{orig}=")
    end
  end

  # As with alias_accessor, but just for the reader.
  # This is basically the same as alias_method.
  #
  def alias_reader(*args)
    orig = args.last
    args = args - [orig]
    args.each do |name|
      alias_method(name, orig)
    end
  end

  # As with alias_method but does the writer instead.
  #
  def alias_writer(*args)
    orig = args.last
    args = args - [orig]
    args.each do |name|
      alias_method("#{name}=", "#{orig}=")
    end
  end

end

Version data entries

20 entries across 19 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/module/alias_accessor.rb
facets-3.1.0 lib/core/facets/module/alias_accessor.rb
facets-3.0.0 lib/core/facets/module/alias_accessor.rb
facets-2.9.3 lib/core/facets/module/alias_accessor.rb
facets-2.9.2 lib/core/facets/module/alias_accessor.rb
facets-2.9.2 src/core/facets/module/alias_accessor.rb
facets-2.9.1 lib/core/facets/module/alias_accessor.rb
facets-2.9.0 lib/core/facets/module/alias_accessor.rb
facets-2.9.0.pre.2 lib/core/facets/module/alias_accessor.rb
facets-2.9.0.pre.1 lib/core/facets/module/alias_accessor.rb
facets-2.8.4 lib/core/facets/module/alias_accessor.rb
facets-2.8.3 lib/core/facets/module/alias_accessor.rb
facets-2.8.2 lib/core/facets/module/alias_accessor.rb
facets-2.8.1 lib/core/facets/module/alias_accessor.rb
facets-2.8.0 lib/core/facets/module/alias_accessor.rb
facets-2.7.0 lib/core/facets/module/alias_accessor.rb
facets-2.6.0 lib/core/facets/module/alias_accessor.rb
facets-2.5.1 lib/core/facets/module/alias_accessor.rb
facets-2.5.0 lib/core/facets/module/alias_accessor.rb
facets-2.5.2 lib/core/facets/module/alias_accessor.rb