aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-07-24 08:57:55 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-07-24 08:57:55 -0700
commit758b2c37776cb0871c65c44061e96076dc5f4dfa (patch)
tree9d0b48cc4bfe94712a77084377a9c01d85aa5203 /activerecord/lib/active_record
parent82a76dfd188223f2856fd92568f51e088be44f31 (diff)
parent098c9c8bc96f70de74358644bd0cdfcd9d20535c (diff)
downloadrails-758b2c37776cb0871c65c44061e96076dc5f4dfa.tar.gz
rails-758b2c37776cb0871c65c44061e96076dc5f4dfa.tar.bz2
rails-758b2c37776cb0871c65c44061e96076dc5f4dfa.zip
Merge pull request #11579 from kennyj/refactor_20130724
Simplify select_one method.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
index 3e79b71fb3..97e1bc5379 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -26,8 +26,7 @@ module ActiveRecord
# 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
@@ -375,14 +374,14 @@ module ActiveRecord
update_sql(sql, name)
end
- def sql_for_insert(sql, pk, id_value, sequence_name, binds)
- [sql, binds]
- end
-
- def last_inserted_id(result)
- row = result.rows.first
- row && row.first
- end
+ def sql_for_insert(sql, pk, id_value, sequence_name, binds)
+ [sql, binds]
+ end
+
+ def last_inserted_id(result)
+ row = result.rows.first
+ row && row.first
+ end
end
end
end