lib/active_record_survey/node/question.rb
def build_answer(answer_node)
			# A survey must either be passed or already present in self.node_maps
			if self.survey.nil?
				raise ArgumentError.new "A survey must be passed if ActiveRecordSurvey::Node::Question is not yet added to a survey"
			end

			# Cannot mix answer types
			# Check if not match existing - throw error
			if !self.answers.select { |answer|
				answer.class != answer_node.class
			}.empty?
				raise ArgumentError.new "Cannot mix answer types on question"
			end

			# Answers actually define how they're built off the parent node
			if answer_node.send(:build_answer, self)

				# If any questions existed directly following this question, insert after this answer
				self.survey.node_maps.select { |i|
					i.node == answer_node && !i.marked_for_destruction?
				}.each { |answer_node_map|
					self.survey.node_maps.select { |j|
						# Same parent
						# Is a question
						!j.marked_for_destruction? &&
						j.parent == answer_node_map.parent && j.node.class.ancestors.include?(::ActiveRecordSurvey::Node::Question)
					}.each { |j|
						answer_node_map.survey = self.survey
						j.survey = self.survey

						answer_node_map.children << j
					}
				}

				true
			end
		end
def build_answer(answer_node)
			# A survey must either be passed or already present in self.node_maps
			if self.survey.nil?
				raise ArgumentError.new "A survey must be passed if ActiveRecordSurvey::Node::Question is not yet added to a survey"
			end

			# Cannot mix answer types
			# Check if not match existing - throw error
			if !self.answers.select { |answer|
				answer.class != answer_node.class
			}.empty?
				raise ArgumentError.new "Cannot mix answer types on question"
			end

			# Answers actually define how they're built off the parent node
			if answer_node.send(:build_answer, self)

				# If any questions existed directly following this question, insert after this answer
				self.survey.node_maps.select { |i|
					i.node == answer_node && !i.marked_for_destruction?
				}.each { |answer_node_map|
					self.survey.node_maps.select { |j|
						# Same parent
						# Is a question
						!j.marked_for_destruction? &&
						j.parent == answer_node_map.parent && j.node.class.ancestors.include?(::ActiveRecordSurvey::Node::Question)
					}.each { |j|
						answer_node_map.survey = self.survey
						j.survey = self.survey

						answer_node_map.children << j
					}
				}

				true
			end
		end
Build an answer off this node