Class: QuestionGroup
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- QuestionGroup
- Includes:
- Surveyor::Models::QuestionGroupMethods
- Defined in:
- lib/surveyor/unparser.rb,
app/models/question_group.rb,
lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb
Instance Method Summary collapse
-
#unparse(dsl) ⇒ Object
block.
Methods included from Surveyor::Models::QuestionGroupMethods
#css_class, #default_args, #dependent?, #display_type=, #help_text_for, #initialize, #renderer, #text_for, #translation, #triggered?
Methods included from Surveyor::MustacheContext
Instance Method Details
#unparse(dsl) ⇒ Object
block
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/surveyor/unparser.rb', line 57 def unparse(dsl) with_defaults = QuestionGroup.new(:text => text) attrs = self.attributes.delete_if{|k,v| with_defaults[k] == v or %w(created_at updated_at id api_id).include?(k) or (k == "display_type" && %w(grid repeater default).include?(v))}.symbolize_keys! method = (%w(grid repeater).include?(display_type) ? display_type : "group") dsl << "\n" dsl << " #{method} \"#{text}\"" dsl << (attrs.blank? ? " do\n" : ", #{attrs.inspect.gsub(/\{|\}/, "")} do\n") questions.first.answers.each{|answer| answer.unparse(dsl)} if display_type == "grid" questions.each{|question| question.unparse(dsl)} dsl << " end\n" end |