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, included, #initialize, #mandatory?, #part_of_group?, #pick=, #renderer, #solo?, #split, #text_for, #translation, #triggered?
Instance Method Details
#unparse(dsl) ⇒ Object
nonblock
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/surveyor/unparser.rb', line 64 def unparse(dsl) attrs = (self.attributes.diff Question.new(:text => text).attributes).delete_if{|k,v| %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 |