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, included, #initialize, #renderer, #text_for, #translation, #triggered?
Methods included from Surveyor::MustacheContext
Instance Method Details
#unparse(dsl) ⇒ Object
block
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/surveyor/unparser.rb', line 50 def unparse(dsl) attrs = (self.attributes.diff QuestionGroup.new(:text => text).attributes).delete_if{|k,v| %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 |