Class: Decidim::Surveys::Survey

Inherits:
ApplicationRecord show all
Includes:
Forms::HasQuestionnaire, HasComponent, Resourceable
Defined in:
decidim-surveys/app/models/decidim/surveys/survey.rb

Overview

The data store for a Survey in the Decidim::Surveys component.

Instance Method Summary collapse

Instance Method Details

#clean_after_publish?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 17

def clean_after_publish?
  component.settings.clean_after_publish?
end

#ends_atObject



25
26
27
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 25

def ends_at
  component.settings.ends_at
end

#open?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 29

def open?
  return true if starts_at.blank? && ends_at.blank?
  return true if ends_at.blank? && starts_at.past?
  return true if starts_at.blank? && ends_at.future?

  return Time.zone.now.between?(starts_at, ends_at) if starts_at.present? && ends_at.present?

  false
end

#starts_atObject



21
22
23
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 21

def starts_at
  component.settings.starts_at
end