Class: Helena::VersionPublisher
- Inherits:
-
Object
- Object
- Helena::VersionPublisher
- Defined in:
- lib/helena/version_publisher.rb
Class Method Summary collapse
- .adjust_copied_attributes(version, copied_version) ⇒ Object
- .build_copied_version_from(version) ⇒ Object
- .newest_version_of(survey) ⇒ Object
- .publish(version) ⇒ Object
Class Method Details
.adjust_copied_attributes(version, copied_version) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/helena/version_publisher.rb', line 17 def self.adjust_copied_attributes(version, copied_version) copied_version.version = newest_version_of(version.survey) + 1 copied_version.survey_detail = version.survey_detail.attributes if version.survey_detail copied_version.created_at = Time.now copied_version.updated_at = Time.now copied_version.active = false copied_version end |
.build_copied_version_from(version) ⇒ Object
30 31 32 33 |
# File 'lib/helena/version_publisher.rb', line 30 def self.build_copied_version_from(version) copied_version = version.clone adjust_copied_attributes(version, copied_version) end |
.newest_version_of(survey) ⇒ Object
26 27 28 |
# File 'lib/helena/version_publisher.rb', line 26 def self.newest_version_of(survey) survey.newest_version.version end |
.publish(version) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/helena/version_publisher.rb', line 3 def self.publish(version) copied_version = build_copied_version_from(version) version.question_groups.each do |original_question_group| question_group = copied_version.question_groups.build original_question_group.clone.attributes original_question_group.questions.each do |original_question| question = question_group.questions.build original_question.clone.attributes question.labels = original_question.labels question.sub_questions = original_question.sub_questions end end copied_version end |