Sha256: 53edac082b0d44a35adf83c2ab1cf928a3fc26442bf8d4b8e9cd31df115877bd

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

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

2 entries across 2 versions & 1 rubygems

Version Path
fozzie-1.1.0 lib/core_ext/module/alias_method_chain.rb
fozzie-1.0.3 lib/core_ext/module/alias_method_chain.rb