Skip to content

Commit

Permalink
Simplify select_one method.
Browse files Browse the repository at this point in the history
The select_all method always returns ActiveRecord::Result instance,
and the ActiveRecord::Result includes Enumerable mixin.
If #empty?, #first method returns nil. Thus we can simplify this method.
  • Loading branch information
kennyj committed Jul 24, 2013
1 parent 3a4d0b1 commit 19291bf
Showing 1 changed file with 1 addition and 2 deletions.
Expand Up @@ -26,8 +26,7 @@ def select_all(arel, name = nil, binds = [])
# Returns a record hash with the column names as keys and column values
# as values.
def select_one(arel, name = nil, binds = [])
result = select_all(arel, name, binds)
result.first if result
select_all(arel, name, binds).first
end

# Returns a single value from a record
Expand Down

0 comments on commit 19291bf

Please sign in to comment.