Sha256: 67625d05ec9abf75f36b68a9a79f797a741739499adf07cb717f1ddba7d9718a
Contents?: true
Size: 904 Bytes
Versions: 1
Compression:
Stored size: 904 Bytes
Contents
module Mongoid module Timespanned extend ActiveSupport::Concern module ClassMethods def timespan_methods name timespan_delegates name timespan_setters name end def timespan_delegates name = :period delegate :time_left, :duration, :start_date, :end_date, to: name end def timespan_setters name = :period define_method :"#{name}_start=" do |date| self.send "#{name}=", ::Timespan.new(start_date: date, end_date: self.send(name).end_date) end define_method :"#{name}_end=" do |date| self.send "#{name}=", ::Timespan.new(start_date: self.send(name).start_date, end_date: date) end define_method :"#{name}duration=" do |duration| self.send "#{name}=", ::Timespan.new(start_date: self.send(name).start_date, duration: duration) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timespan-0.4.3 | lib/timespan/mongoid/timespanned.rb |