Method: Module#alias_method_chain_with_prevent_repeat_aliasing
- Defined in:
- lib/qualitysmith_extensions/module/alias_method_chain.rb
#alias_method_chain_with_prevent_repeat_aliasing(target, feature, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/qualitysmith_extensions/module/alias_method_chain.rb', line 31 def alias_method_chain_with_prevent_repeat_aliasing(target, feature, &block) # 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 target_without_feature = "#{aliased_target}_without_#{feature}#{punctuation}" #puts "#{target} is #{method_defined?(target)}" alias_method_chain_without_prevent_repeat_aliasing(target, feature, &block) unless method_defined?(target_without_feature) end |