YUKI Hiroshi
null+****@clear*****
Tue Dec 25 16:14:45 JST 2012
YUKI Hiroshi 2012-12-25 16:14:45 +0900 (Tue, 25 Dec 2012) New Revision: f680b190a4663c283ced288780aa74e140c5c6e6 https://github.com/groonga/gcs/commit/f680b190a4663c283ced288780aa74e140c5c6e6 Log: Simplify methods to store creation date and update date Modified files: lib/database/domain.js Modified: lib/database/domain.js (+18 -18) =================================================================== --- lib/database/domain.js 2012-12-25 11:21:23 +0900 (224fa51) +++ lib/database/domain.js 2012-12-25 16:14:45 +0900 (73d64c3) @@ -256,41 +256,41 @@ Domain.prototype = { this.setConfiguration(this.defaultSearchFieldConfigurationKey, value.name); } var now = new Date(); - if (!this.getConfiguration(this.getOptionCreationDateKey('defaultSearchField'))) - this.setOptionCreationDate('defaultSearchField', now); - this.setOptionUpdateDate('defaultSearchField', now); + if (!this.getConfiguration(this.getCreationDateKey('option_defaultSearchField'))) + this.setCreationDate('option_defaultSearchField', now); + this.setUpdateDate('option_defaultSearchField', now); return value; }, get defaultSearchFieldConfigurationKey() { return 'default_search_field'; }, - getOptionCreationDate: function(name) { + getCreationDate: function(key) { var storedDate = this.exists() ? - this.getConfiguration(this.getOptionCreationDateKey(name)) : null ; + this.getConfiguration(this.getCreationDateKey(key)) : null ; return storedDate ? new Date(storedDate) : new Date(); }, - setOptionCreationDate: function(name, date) { + setCreationDate: function(name, date) { if (this.exists()) - this.setConfiguration(this.getOptionCreationDateKey(name), date.getTime()) + this.setConfiguration(this.getCreationDateKey(key), date.getTime()) return date; }, - getOptionCreationDateKey: function(option) { - return 'option_' + option + '_created_at'; + getCreationDateKey: function(base) { + return base + '_created_at'; }, - getOptionUpdateDate: function(name) { + getUpdateDate: function(key) { var storedDate = this.exists() ? - this.getConfiguration(this.getOptionUpdateDateKey(name)) : null ; + this.getConfiguration(this.getUpdateDateKey(key)) : null ; return storedDate ? new Date(storedDate) : new Date(); }, - setOptionUpdateDate: function(name, date) { + setUpdateDate: function(key, date) { if (this.exists()) - this.setConfiguration(this.getOptionUpdateDateKey(name), date.getTime()) + this.setConfiguration(this.getUpdateDateKey(key), date.getTime()) return date; }, - getOptionUpdateDateKey: function(option) { - return 'option_' + option + '_updated_at'; + getUpdateDateKey: function(key) { + return key + '_updated_at'; }, get id() { @@ -499,9 +499,9 @@ Domain.prototype = { }); var now = new Date(); - if (!this.getConfiguration(this.getOptionCreationDateKey('synonyms'))) - this.setOptionCreationDate('synonyms', now); - this.setOptionUpdateDate('synonyms', now); + if (!this.getConfiguration(this.getCreationDateKey('option_synonyms'))) + this.setCreationDate('option_synonyms', now); + this.setUpdateDate('option_synonyms', now); return this; }, -------------- next part -------------- HTML����������������������������... Download