Module: StateFu::Interface::SoftAlias
- Defined in:
- lib/interface.rb
Instance Method Summary collapse
-
#soft_alias(x) ⇒ Object
define aliases that won’t clobber existing methods - so we can be liberal with them.
Instance Method Details
#soft_alias(x) ⇒ Object
define aliases that won’t clobber existing methods - so we can be liberal with them.
7 8 9 10 11 12 13 14 |
# File 'lib/interface.rb', line 7 def soft_alias(x) aliases = [ x.to_a[0] ].flatten original = aliases.shift existing_method_names = (self.instance_methods | self.protected_instance_methods | self.private_instance_methods).map(&:to_sym) taken, ok = aliases.partition { |a| existing_method_names.include?(a.to_sym) } StateFu::Logger.debug("#{self.to_s} alias for ## #{original} already taken: #{taken.inspect}") unless taken.empty? ok.each { |a| alias_method a, original} end |