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)

15
16
17
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 15

def clean_after_publish?
  component.settings.clean_after_publish?
end

#ends_atObject


23
24
25
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 23

def ends_at
  component.settings.ends_at
end

#open?Boolean

Returns:

  • (Boolean)

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

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


19
20
21
# File 'decidim-surveys/app/models/decidim/surveys/survey.rb', line 19

def starts_at
  component.settings.starts_at
end