Sha256: 94c651f27f3a68f6d5c8c0e10f76ad3b12345bcf9532cfc9dec89443c43ccbc4
Contents?: true
Size: 962 Bytes
Versions: 1
Compression:
Stored size: 962 Bytes
Contents
module Appt class Calendar < ActiveRecord::Base serialize :availability, WorkhoursSerializer has_many :appointments, dependent: :destroy has_many :blocks, dependent: :destroy has_many :external_calendars, ->{ distinct }, through: :blocks validates :timezone_name, presence: true, inclusion: { in: ActiveSupport::TimeZone.all.map(&:name).freeze } validates :name, :availability, presence: true def availability_text availability.try(:export).try(:[], :hours).try(:join, "\n") end def availability_text=(value) value ||= '' self.availability = Workhours::Week.new(hours: value.split("\n").reject(&:blank?).map(&:strip)) end def timezone ActiveSupport::TimeZone[timezone_name] end def local_time_of_day(date, tod) date.at(tod, timezone) end def now timezone.now end def today now.to_date end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appt-0.0.1.beta.3 | app/models/appt/calendar.rb |