Sha256: e19a7cd600d24de9f996afe91bfe903846a2faee089d79c0f1126511871403f0

Contents?: true

Size: 419 Bytes

Versions: 4

Compression:

Stored size: 419 Bytes

Contents

class Hash
  def __evolve_to_timespan__
    serializer = Mongoid::Fields::Timespan
    object = self
    # puts "evolve from: #{self}"
    ::Timespan.new :from => serializer.from(object), :to => serializer.to(object), asap: serializer.asap(object)
  end

  def __evolve_to_duration_range__
    range = Range.new (self['from'] || self[:from]), (self['to'] || self[:to])
    ::DurationRange.new range, :seconds
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
timespan-0.5.5 lib/timespan/core_ext/hash.rb
timespan-0.5.4 lib/timespan/core_ext/hash.rb
timespan-0.5.3 lib/timespan/core_ext/hash.rb
timespan-0.5.2 lib/timespan/core_ext/hash.rb