Browse files

Use #public_methods to check whether a command method is public, rath…

…er than private_methods+protected_methods.

(Works around bug #204 in MacRuby)
  • Loading branch information...
1 parent 23b32a2 commit 677b1e02b2e97940bb7dddf3de63cd753b2b10c2 @nerdyc nerdyc committed Jun 4, 2011
Showing with 2 additions and 3 deletions.
  1. +2 −3 lib/thor/task.rb
View
5 lib/thor/task.rb
@@ -65,10 +65,9 @@ def required_options
@required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ")
end
- # Given a target, checks if this class name is not a private/protected method.
+ # Given a target, checks if this class name is a public method.
def public_method?(instance) #:nodoc:
- collection = instance.private_methods + instance.protected_methods
- (collection & [name.to_s, name.to_sym]).empty?
+ !(instance.public_methods & [name.to_s, name.to_sym]).empty?
end
def sans_backtrace(backtrace, caller) #:nodoc:

0 comments on commit 677b1e0

Please sign in to comment.