Class: Question
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Question
- Includes:
- Surveyor::Models::QuestionMethods
- Defined in:
- app/models/question.rb,
lib/surveyor/unparser.rb,
lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb
Instance Method Summary collapse
-
#unparse(dsl) ⇒ Object
nonblock.
Methods included from Surveyor::Models::QuestionMethods
#css_class, #default_args, #dependent?, #display_type=, #help_text_for, #initialize, #mandatory?, #part_of_group?, #pick=, #renderer, #solo?, #split, #text_for, #translation, #triggered?
Methods included from Surveyor::MustacheContext
Instance Method Details
#unparse(dsl) ⇒ Object
nonblock
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/surveyor/unparser.rb', line 72 def unparse(dsl) with_defaults = Question.new(:text => text) attrs = self.attributes.delete_if{|k,v| with_defaults[k] == v or %w(created_at updated_at reference_identifier id survey_section_id question_group_id api_id).include?(k) or (k == "display_type" && v == "label")}.symbolize_keys! dsl << (solo? ? "\n" : " ") if display_type == "label" dsl << " label" else dsl << " q" end dsl << "_#{reference_identifier}" unless reference_identifier.blank? dsl << " \"#{text}\"" dsl << (attrs.blank? ? "\n" : ", #{attrs.inspect.gsub(/\{|\}/, "")}\n") if solo? or question_group.display_type != "grid" answers.each{|answer| answer.unparse(dsl)} end dependency.unparse(dsl) if dependency end |