Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/active_warehouse/compat/compat.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#alias_method_chain(target, feature) {|aliased_target, punctuation| ... } ⇒ Object

Yields:

  • (aliased_target, punctuation)


41
42
43
44
45
46
47
48
# File 'lib/active_warehouse/compat/compat.rb', line 41

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?
  alias_method "#{aliased_target}_without_#{feature}#{punctuation}", target
  alias_method target, "#{aliased_target}_with_#{feature}#{punctuation}"
end