Navigation Menu

Skip to content

Commit

Permalink
rename_method needs to test method_defined? rather than respond_to?
Browse files Browse the repository at this point in the history
  • Loading branch information
brentr committed Feb 27, 2015
1 parent 83510b4 commit c30c1b6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mbari.rb
@@ -1,8 +1,6 @@
#################### mbari.rb -- brent@mbari.org #####################
# $Source: /home/cvs/ESP/gen2/software/ruby/mbari.rb,v $
# $Id: mbari.rb,v 1.18 2007/11/25 23:03:20 brent Exp $
#
# MBARI Generic (application-independent) utilites
# MBARI Generic (application-independent) utilites -- revised: 2/26/15
#
# Selected Methods:
# Module.rename_method -> alias_method only if alias dosn't already exist
Expand Down Expand Up @@ -59,7 +57,7 @@ def ord


class Module
unless defined? constants_at
unless respond_to? :constants_at
def constants_at
#return Array of names of constants defined in specified module
acs = ancestors
Expand All @@ -77,12 +75,12 @@ def constants_at

private
def rename_method newId,oldId
alias_method newId, oldId unless respond_to? newId
alias_method newId, oldId unless method_defined? newId
end
end

class Hash
def join (sep = " => ", m=:to_s)
def join(sep = " => ", m=:to_s)
# most useful for displaying hashes with puts hsh.join
strAry = []
each {|key,value| strAry << key.inspect+sep+value.method(m).call}
Expand Down

0 comments on commit c30c1b6

Please sign in to comment.