Module: Nexo::CalendarEvent

Extended by:
ActiveSupport::Concern
Includes:
Synchronizable
Defined in:
app/models/concerns/nexo/calendar_event.rb

Instance Method Summary collapse

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

Returns:

  • (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

Returns:

  • (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_fromObject



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_toObject



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_columnsObject

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

#transparencyObject

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