Class: Date

Inherits:
Object show all
Defined in:
lib/mongodoc/ext/date.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bson_create(bson_hash, options = nil) ⇒ Object



12
13
14
# File 'lib/mongodoc/ext/date.rb', line 12

def self.bson_create(bson_hash, options = nil)
  Date.parse(*bson_hash.values_at('dt', 'sg'))
end

Instance Method Details

#to_bson(*args) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/mongodoc/ext/date.rb', line 2

def to_bson(*args)
  {
    MongoDoc::BSON::CLASS_KEY => self.class.name,
    'dt' => strftime,
    'sg' => start
  }
end