Sha256: d752b7e0f4ecf274c815ac79439aa1cdddc31d774f270786daa91c19e954074d

Contents?: true

Size: 710 Bytes

Versions: 8

Compression:

Stored size: 710 Bytes

Contents

# Module overloads
class Module
  # Gives us alias_method_chain from rails
  def alias_method_chain(target, feature)
    aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
    yield(aliased_target, punctuation) if block_given?

    with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"

    alias_method without_method, target
    alias_method target, with_method

    case
      when public_method_defined?(without_method)
        public target
      when protected_method_defined?(without_method)
        protected target
      when private_method_defined?(without_method)
        private target
    end
  end
end

Version data entries

8 entries across 8 versions & 4 rubygems

Version Path
auser-poolparty-0.0.8 lib/core/module.rb
auser-poolparty-0.0.9 lib/core/module.rb
auser-poolparty-0.1.0 lib/core/module.rb
auser-poolparty-0.1.1 lib/core/module.rb
auser-poolparty-0.1.2 lib/core/module.rb
dreadpiratepj-poolparty-0.0.8 lib/core/module.rb
jtzemp-poolparty-0.1.2 lib/core/module.rb
poolparty-0.0.4 lib/core/module.rb