Sha256: 3c1174330c2873dbd8fc8288d564634a4af9786a46198e81d1083509310c8d68

Contents?: true

Size: 430 Bytes

Versions: 28

Compression:

Stored size: 430 Bytes

Contents

class Module
  # Encapsulates the common pattern of:
  #
  #   alias_method :foo_without_feature, :foo
  #   alias_method :foo, :foo_with_feature
  #
  # With this, you simply do:
  #
  #   alias_method_chain :foo, :feature
  #
  # And both aliases are set up for you.
  def alias_method_chain(target, feature)
    alias_method "#{target}_without_#{feature}", target
    alias_method target, "#{target}_with_#{feature}"
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
gamebox-0.5.5 lib/gamebox/lib/aliasing.rb
gamebox-0.5.4 lib/gamebox/lib/aliasing.rb
gamebox-0.5.2 lib/gamebox/lib/aliasing.rb
gamebox-0.5.1 lib/gamebox/lib/aliasing.rb
gamebox-0.5.0 lib/gamebox/lib/aliasing.rb
gamebox-0.4.1 lib/gamebox/lib/aliasing.rb
gamebox-0.4.0 lib/gamebox/lib/aliasing.rb
gamebox-0.4.0.rc11 lib/gamebox/lib/aliasing.rb
gamebox-0.4.0.rc5 lib/gamebox/lib/aliasing.rb
gamebox-0.4.0.rc4 lib/gamebox/lib/aliasing.rb
gamebox-0.4.0.rc3 lib/gamebox/lib/aliasing.rb
gamebox-0.4.0.rc2 lib/gamebox/lib/aliasing.rb
gamebox-0.4.0.rc1 lib/gamebox/lib/aliasing.rb
gamebox-0.3.4 lib/gamebox/lib/aliasing.rb
gamebox-0.3.3 lib/gamebox/lib/aliasing.rb
gamebox-0.3.2 lib/gamebox/lib/aliasing.rb
gamebox-0.2.1 lib/gamebox/lib/aliasing.rb
gamebox-0.1.1 lib/gamebox/lib/aliasing.rb
gamebox-0.1.0 lib/gamebox/lib/aliasing.rb
gamebox-0.0.9 lib/gamebox/lib/aliasing.rb