Skip to content

Commit

Permalink
Make control flow more obvious by getting rid of multiple returns
Browse files Browse the repository at this point in the history
  • Loading branch information
semaperepelitsa committed Jan 30, 2012
1 parent 5669779 commit 0cb957f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/mongoid/fields/mappings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ module Mappings
#
# @since 2.1.0
def for(klass, foreign_key = false)
return Internal::Object unless klass
if foreign_key
return MODULE::ForeignKeys.const_get(klass.to_s.demodulize)
end
begin
if klass.nil?
Internal::Object
elsif foreign_key
MODULE::ForeignKeys.const_get(klass.to_s.demodulize)
else
modules = "BSON::|ActiveSupport::"
match = klass.to_s.match(Regexp.new("^(#{ modules })?(\\w+)$"))
if match and MODULE.const_defined?(match[2])
Expand Down

0 comments on commit 0cb957f

Please sign in to comment.