Sha256: 02ccf0aa3e2148257873542a7fc2c7d4e367c3b6fa951e15ccb812e524c6afad

Contents?: true

Size: 899 Bytes

Versions: 9

Compression:

Stored size: 899 Bytes

Contents

class Module

  # Custom alias_method_chain that won't cause infinite recursion if
  # called twice.
  # Calling alias_method_chain on alias_method_chain
  # was just way to confusing, so I copied it :-/
  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?
    without = "#{aliased_target}_without_#{feature}#{punctuation}"
    unless method_defined?(without)
      alias_method without, target
      alias_method target, "#{aliased_target}_with_#{feature}#{punctuation}"
    end
  end

  # we used to have a delegate in here that didn't go bang if 'to' is
  # nil.  If you relied on it, use the new :allow_nil option with
  # active_support's delegate

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hobo_support-2.2.6 lib/hobo_support/fixes/module.rb
hobo_support-2.2.5 lib/hobo_support/fixes/module.rb
hobo_support-2.2.4 lib/hobo_support/fixes/module.rb
hobo_support-2.2.3 lib/hobo_support/fixes/module.rb
hobo_support-2.2.2 lib/hobo_support/fixes/module.rb
hobo_support-2.2.1 lib/hobo_support/fixes/module.rb
hobo_support-2.2.0 lib/hobo_support/fixes/module.rb
hobo_support-2.1.2 lib/hobo_support/fixes/module.rb
hobo_support-2.1.1 lib/hobo_support/fixes/module.rb