lib/active_groonga/persistence.rb in activegroonga-4.0.0 vs lib/active_groonga/persistence.rb in activegroonga-4.2.0
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
+# Copyright (C) 2009-2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
@@ -102,11 +102,13 @@
if table.support_key?
record = table.add(key, attributes)
else
record = table.add(attributes)
end
- record["created_at"] = Time.now if record.have_column?("created_at")
+ current_time = Time.now
+ record["created_at"] = current_time if record.have_column?("created_at")
+ record["updated_at"] = current_time if record.have_column?("updated_at")
reload_attributes(record)
@id = record.id
@key = record.key if record.support_key?
@new_record = false
true
@@ -140,10 +142,10 @@
if record.support_key?
attributes["key"] = record.key
else
attributes["id"] = record.id
end
- attributes["score"] = record.score if record.support_sub_records?
+ attributes["score"] = record.score if record.support_score?
record.columns.each do |column|
next if column.is_a?(Groonga::IndexColumn)
value = record[column.local_name]
if value and column.reference?
value_class = self.class.custom_reference_class(column.local_name)