Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Commit

Permalink
Changed created_at types from Time to DateTime for BaseCommand and Ba…
Browse files Browse the repository at this point in the history
…seEvent.

Details:
* The DateTime class is more robust than the Time class (Unix posix wrapper).
  • Loading branch information
byu committed Nov 18, 2010
1 parent 0d7a383 commit a393299
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/junkfood/ceb/base_command.rb
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'date'
require 'junkfood/ceb/bus'
require 'mongoid'

Expand Down Expand Up @@ -72,7 +73,7 @@ class BaseCommand
:inverse_of => :command,
:class_name => 'Junkfood::Ceb::BaseEvent')

field :created_at, :type => Time
field :created_at, :type => DateTime
field :origin, :type => String

after_initialize :generate_default_values
Expand All @@ -89,7 +90,7 @@ def perform
# Before create hook to set the Command's default values.
#
def generate_default_values
self.created_at = Time.now unless self.created_at
self.created_at = DateTime.now unless self.created_at
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/junkfood/ceb/base_event.rb
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'date'
require 'mongoid'

module Junkfood
Expand Down Expand Up @@ -43,7 +44,7 @@ module Ceb
class BaseEvent
include Mongoid::Document

field :created_at, :type => Time
field :created_at, :type => DateTime

referenced_in :command, :class_name => 'Junkfood::Ceb::BaseCommand'

Expand All @@ -52,7 +53,7 @@ class BaseEvent
protected

def generate_default_values
self.created_at = Time.now unless self.created_at
self.created_at = DateTime.now unless self.created_at
end
end
end
Expand Down

0 comments on commit a393299

Please sign in to comment.