blob: f50b4237ce61529ee83478a2cd5e4e5c61654329 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  | 
class Calendar < ApplicationModel
  class DateValue
    include ActiveAttr::Model
    attribute :id, type: Integer
    attribute :value, type: Date
    validates_presence_of :value
    def self.from_date(index, date)
      new id: index, value: date
    end
    # Stuff required for coocon
    def new_record?
      !persisted?
    end
    def persisted?
      id.present?
    end
    def mark_for_destruction
      self._destroy = true
    end
    attribute :_destroy, type: Boolean
    alias_method :marked_for_destruction?, :_destroy
  end
end
  |