Skip to content

Commit

Permalink
Refactor case syntax to be more compact
Browse files Browse the repository at this point in the history
  • Loading branch information
agis committed Nov 20, 2012
1 parent 4f71c91 commit 1308bff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions lib/thor/base.rb
Expand Up @@ -313,12 +313,12 @@ def remove_class_option(*names)
# name<String|Symbol>
#
def group(name=nil)
case name
when nil
@group ||= from_superclass(:group, 'standard')
else
@group = name.to_s
end
@group = case name
when nil
@group || from_superclass(:group, 'standard')
else
name.to_s
end
end

# Returns the tasks for this Thor class.
Expand Down Expand Up @@ -413,12 +413,12 @@ def no_tasks
# thor :my_task
#
def namespace(name=nil)
case name
when nil
@namespace ||= Thor::Util.namespace_from_thor_class(self)
else
@namespace = name.to_s
end
@namespace = case name
when nil
@namespace || Thor::Util.namespace_from_thor_class(self)
else
@namespace = name.to_s
end
end

# Parses the task and options from the given args, instantiate the class
Expand Down
12 changes: 6 additions & 6 deletions lib/thor/group.rb
Expand Up @@ -14,12 +14,12 @@ class << self
# description<String>:: The description for this Thor::Group.
#
def desc(description=nil)
case description
when nil
@desc ||= from_superclass(:desc, nil)
else
@desc = description
end
@desc = case description
when nil
@desc || from_superclass(:desc, nil)
else
description
end
end

# Prints help information.
Expand Down

0 comments on commit 1308bff

Please sign in to comment.