Class: Mongoid::TimeRange
- Inherits:
-
Hash
- Object
- Hash
- Mongoid::TimeRange
- Defined in:
- lib/mongoid/time_range.rb,
lib/mongoid/time_range/version.rb
Constant Summary collapse
- VERSION =
'0.5.0'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(from = Time.now, to = nil) ⇒ TimeRange
constructor
A new instance of TimeRange.
- #mongoize ⇒ Object
Constructor Details
#initialize(from = Time.now, to = nil) ⇒ TimeRange
Returns a new instance of TimeRange.
6 7 8 |
# File 'lib/mongoid/time_range.rb', line 6 def initialize(from = Time.now, to = nil) merge! from: from, to: to end |
Class Method Details
.demongoize(hash) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/mongoid/time_range.rb', line 31 def demongoize(hash) return if hash.nil? hash = hash.symbolize_keys new(Time.demongoize(hash[:from]), Time.demongoize(hash[:to])) end |
.mongoize(object) ⇒ Object
27 28 29 |
# File 'lib/mongoid/time_range.rb', line 27 def mongoize(object) { from: Time.mongoize(object[:from]), to: Time.mongoize(object[:to]) } end |
Instance Method Details
#mongoize ⇒ Object
22 23 24 |
# File 'lib/mongoid/time_range.rb', line 22 def mongoize self.class.mongoize(self) end |