Skip to content

Commit

Permalink
Pimp up Builder#derive's signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
david committed Jun 16, 2011
1 parent c8b99a0 commit a6af6cb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/bricks/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,24 @@ def ~@()
self
end

def derive(klass = @class, save = @save)
def derive(*args)
klass, save = case args.size
when 2
args
when 1
case args.first
when Class
[args.first, @save]
else
[@class, args.first]
end
when 0
[@class, @save]
else
raise ArgumentError, "wrong number of arguments " +
"(#{args.size} for 0, 1 or 2)"
end

Builder.new(klass, @attrs, @traits, save)
end

Expand Down

0 comments on commit a6af6cb

Please sign in to comment.