Module: Nexo::CalendarEvent
- Extended by:
- ActiveSupport::Concern
- Includes:
- Synchronizable
- Defined in:
- app/models/concerns/nexo/calendar_event.rb
Instance Method Summary collapse
- #all_day? ⇒ Boolean
- #change_is_significative_to_sequence? ⇒ Boolean
- #datetime_from ⇒ Object
- #datetime_to ⇒ Object
-
#significative_columns ⇒ Object
Model columns relevant to the sequence.
-
#transparency ⇒ Object
transparent: non blocking opaque: blocking.
- #validate_synchronizable! ⇒ Object
Methods included from Synchronizable
#conflicted?, #increment_sequence!, #method_missing, #protocol_methods, #translate_fields, #update_from_fields!
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Nexo::Synchronizable
Instance Method Details
#all_day? ⇒ Boolean
42 43 44 |
# File 'app/models/concerns/nexo/calendar_event.rb', line 42 def all_day? time_from.blank? && time_to.blank? end |
#change_is_significative_to_sequence? ⇒ Boolean
22 23 24 |
# File 'app/models/concerns/nexo/calendar_event.rb', line 22 def change_is_significative_to_sequence? previous_changes.keys.map(&:to_sym).intersection(significative_columns).any? end |
#datetime_from ⇒ Object
34 35 36 |
# File 'app/models/concerns/nexo/calendar_event.rb', line 34 def datetime_from build_date_time(date_from, time_from) end |
#datetime_to ⇒ Object
38 39 40 |
# File 'app/models/concerns/nexo/calendar_event.rb', line 38 def datetime_to build_date_time(date_to, time_to) end |
#significative_columns ⇒ Object
Model columns relevant to the sequence
By default is equal to protocol_methods, but each concrete model class could have its own specific column names
30 31 32 |
# File 'app/models/concerns/nexo/calendar_event.rb', line 30 def significative_columns protocol_methods end |
#transparency ⇒ Object
transparent: non blocking opaque: blocking
48 49 50 51 52 53 54 |
# File 'app/models/concerns/nexo/calendar_event.rb', line 48 def transparency if all_day? "transparent" else "opaque" end end |
#validate_synchronizable! ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/concerns/nexo/calendar_event.rb', line 56 def validate_synchronizable! unless datetime_from.present? raise Errors::SynchronizableInvalid, "datetime_from is nil" end unless datetime_to.present? raise Errors::SynchronizableInvalid, "datetime_to is nil" end unless datetime_from != datetime_to raise Errors::SynchronizableInvalid, "datetime_from and datetime_to are equal" end unless summary.present? raise Errors::SynchronizableInvalid, "summary is nil" end end |