Sha256: e7289a635f8fe537b46a368715561889209dde7b47a7361474b038727b0bea55
Contents?: true
Size: 774 Bytes
Versions: 3
Compression:
Stored size: 774 Bytes
Contents
require "active_support/core_ext/module/aliasing" # *Correct* `alias_method_chain_once` implementation class Module def alias_method_chain_once(target, feature) aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1 without_method = "#{aliased_target}_without_#{feature}#{punctuation}" # `method_defined?` matches public and protected methods, # also `*_method_defined?` family of methods is the portable # way to check for method existence, while `public_methods.include?` # will work either on 1.8 or 1.9 (depending on where symbol or string # is provided as method name) unless method_defined?(without_method) || private_method_defined?(without_method) alias_method_chain(target, feature) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dolzenko-0.0.27 | lib/dolzenko/alias_method_chain_once.rb |
dolzenko-0.0.26 | lib/dolzenko/alias_method_chain_once.rb |
dolzenko-0.0.25 | lib/dolzenko/alias_method_chain_once.rb |