lib/couch_surfer/model.rb in couch_surfer-0.3.3 vs lib/couch_surfer/model.rb in couch_surfer-0.3.4
- old
+ new
@@ -13,19 +13,10 @@
def self.default_database= db
@database = db
end
- # Adapted from ActiveSupport Time#formatted_offset
- def self.format_utc_offset(time)
- seconds_offset_from_utc = time.utc_offset
- sign = (seconds_offset_from_utc < 0 ? -1 : 1)
- hours = seconds_offset_from_utc.abs / 3600
- minutes = (seconds_offset_from_utc.abs % 3600) / 60
- "%+03d%02d" % [ hours * sign, minutes ]
- end
-
module ClassMethods
# override the CouchSurfer::Model-wide default_database
def use_database db
self.class_database = db
end
@@ -162,12 +153,10 @@
define_method method do
Time.parse(@attributes[method])
end
end
before(:save) do
- time = Time.now
- utc_offset = CouchSurfer::Model.format_utc_offset(time)
- self['updated_at'] = time.strftime("%Y/%m/%d %H:%M:%S.#{time.usec} #{utc_offset}")
+ self['updated_at'] = Time.now
self['created_at'] = self['updated_at'] if new_document?
end
end
# Name a method that will be called before the document is first saved,
\ No newline at end of file