Sha256: f8c1af0cad65de78dd19da2d73f80954f2182701d38e0dd77da932855e74059f

Contents?: true

Size: 960 Bytes

Versions: 14

Compression:

Stored size: 960 Bytes

Contents

class Module
  # Standard in rails... See official documentation[http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Module.html]
  def alias_method_chain(target, feature)
    # Strip out punctuation on predicates or bang methods since
    # e.g. target?_without_feature is not a valid method name.
    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 unless method_defined? :alias_method_chain
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
marcandre-backports-1.0.1 lib/backports/module.rb
marcandre-backports-1.1.1 lib/backports/module.rb
marcandre-backports-1.2.0 lib/backports/module.rb
marcandre-backports-1.3.0 lib/backports/module.rb
marcandre-backports-1.3.1 lib/backports/module.rb
marcandre-backports-1.4.0 lib/backports/module.rb
marcandre-backports-1.5.0 lib/backports/module.rb
backports-1.1.0 lib/backports/module.rb
backports-1.2.0 lib/backports/module.rb
backports-1.0.0 lib/backports/module.rb
backports-1.3.0 lib/backports/module.rb
backports-1.1.1 lib/backports/module.rb
backports-1.5.0 lib/backports/module.rb
backports-1.3.1 lib/backports/module.rb