mongoid_occurrence_views 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa268d9e2656e8b35616ab70bcf40d92bd40c9a7e4cf9a11b8aaf793579fa12f
4
- data.tar.gz: 4892510c48dc5f11900721465971a7968a8d77b7fa22237ceb3af39afedcc6cd
3
+ metadata.gz: c3ffeb3d7b442d27f68887e73ec5d02b84d9e35b391d2d498a65c4982b636112
4
+ data.tar.gz: da20afd3da6af7d2f027bb16868ef74151c31f1403dcd6847337c15a8f914d55
5
5
  SHA512:
6
- metadata.gz: 328d2122351ec35fb11b8fa09a72a0635e8d49aeab5cea001ae56b46c4b9ba527370658a5e20668c874aec01ea78163d703efe8fe32fa456fa5c605db085508d
7
- data.tar.gz: 329f2f783191b3a038e2808e7c90ceceb52dde6ddb514f8c46a2c605d3d6a1794d4d0f76c4764e816d651c7c9a899df284b4dfb1bcf62ba2301d3d5cced9714f
6
+ metadata.gz: d2c07710cb02f5e2ac2c12b0bcc35acd64b01b830d44c1cf326c69fd2fb88e3e3b1b47483f8c6ad9b60ac2289079952976b4d4b79b061c8e2b9d2d1e1c462854
7
+ data.tar.gz: 563f4d924c63357793699d99539be0b724acb90d74e6364c262491726bd9c7b0c70c40d7d711653135dfc48a168e86d9a1a043ddca121ef3750df9406c7cbd32
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.0
4
+
5
+ * [PR#3](https://github.com/tomasc/mongoid_occurrence_views/pull/3) `all_day` becomes a field
6
+
3
7
  ## 0.1.1
4
8
 
5
9
  * [PR#2](https://github.com/tomasc/mongoid_occurrence_views/pull/2) allow :assign_daily_occurrences to be triggerred manually
@@ -18,6 +18,13 @@ module MongoidOccurrenceViews
18
18
  DateTime.demongoize(self[:_dtend])
19
19
  end
20
20
 
21
+ def all_day
22
+ return unless dtstart.present? && dtend.present?
23
+ dtstart.to_i == dtstart.beginning_of_day.to_i &&
24
+ dtend.to_i == dtend.end_of_day.to_i
25
+ end
26
+ alias all_day? all_day
27
+
21
28
  module ClassMethods
22
29
  def occurrences_ordering_view_name
23
30
  [collection.name, ORDERING_VIEW_NAME_SUFFIX].join('__').freeze
@@ -12,6 +12,7 @@ module MongoidOccurrenceViews
12
12
  def embedded_in_event(options = {})
13
13
  field :dtstart, type: DateTime
14
14
  field :dtend, type: DateTime
15
+ field :all_day, type: Boolean
15
16
 
16
17
  field :schedule, type: MongoidIceCubeExtension::Schedule
17
18
  field :schedule_dtend, type: Time
@@ -38,17 +39,14 @@ module MongoidOccurrenceViews
38
39
  end
39
40
 
40
41
  def all_day
41
- return unless dtstart.present?
42
- return unless dtend.present?
42
+ return super unless dtstart.present? && dtend.present?
43
+ return super unless super.nil?
43
44
 
44
- @all_day ||= dtstart == dtstart.beginning_of_day && dtend == dtend.end_of_day
45
+ dtstart.to_i == dtstart.beginning_of_day.to_i &&
46
+ dtend.to_i == dtend.end_of_day.to_i
45
47
  end
46
48
  alias all_day? all_day
47
49
 
48
- def all_day=(val)
49
- @all_day = [true, 'true', 1, '1'].include?(val)
50
- end
51
-
52
50
  def recurring?
53
51
  schedule.present?
54
52
  end
@@ -66,8 +64,8 @@ module MongoidOccurrenceViews
66
64
  def adjust_dates_for_all_day
67
65
  return unless all_day?
68
66
 
69
- self.dtstart = dtstart.beginning_of_day
70
- self.dtend = dtend.end_of_day
67
+ write_attribute(:dtstart, dtstart.try(:beginning_of_day))
68
+ write_attribute(:dtend, dtend.try(:end_of_day))
71
69
  end
72
70
 
73
71
  def assign_daily_occurrences
@@ -87,6 +85,7 @@ module MongoidOccurrenceViews
87
85
 
88
86
  def daily_occurrences_from_date_range
89
87
  return [] if recurring?
88
+
90
89
  date_range = Range.new(dtstart.to_date, dtend.to_date)
91
90
  is_single_day = (date_range.first == date_range.last)
92
91
 
@@ -109,10 +108,10 @@ module MongoidOccurrenceViews
109
108
  field :de, as: :dtend, type: DateTime
110
109
 
111
110
  def all_day
112
- return unless dtstart.present?
113
- return unless dtend.present?
111
+ return unless dtstart.present? && dtend.present?
114
112
 
115
- dtstart == dtstart.beginning_of_day && dtend == dtend.end_of_day
113
+ dtstart.to_i == dtstart.beginning_of_day.to_i &&
114
+ dtend.to_i == dtend.end_of_day.to_i
116
115
  end
117
116
  alias all_day? all_day
118
117
  end
@@ -1,3 +1,3 @@
1
1
  module MongoidOccurrenceViews
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_occurrence_views
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna