Sha256: bd7396ed9d6ac38565bd9ed5a1d6cdeeb5accff1e104e39cf54da6ba20e00e30
Contents?: true
Size: 831 Bytes
Versions: 2
Compression:
Stored size: 831 Bytes
Contents
require 'mongoid' module MongoidRecurring class Occurence include Mongoid::Document field :dtstart, type: DateTime field :dtend, type: DateTime attr_accessor :all_day embedded_in :schedule, class_name: 'MongoidRecurring::Occurence' validates :dtstart, presence: true validates :dtend, presence: true before_save :set_dtend before_save :adjust_dates_for_all_day # ===================================================================== def all_day? self.all_day == true end private # ============================================================= def set_dtend self.dtend ||= dtstart end def adjust_dates_for_all_day return unless all_day? self.dtstart = dtstart.beginning_of_day self.dtend = dtend.end_of_day end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid_recurring-0.1.1 | lib/mongoid_recurring/occurence.rb |
mongoid_recurring-0.1.0 | lib/mongoid_recurring/occurence.rb |