Sha256: 3a61119881c076b507d1cbcb5a0bd8b4e0f4f01756d93f8b7fde0d6adf2f7136
Contents?: true
Size: 942 Bytes
Versions: 8
Compression:
Stored size: 942 Bytes
Contents
module ActiveRecordSurvey class Node::Question < Node # Stop validating at the Question node def validate_parent_instance_node(instance_node, child_node) !self.node_validations.collect { |node_validation| node_validation.validate_instance_node(instance_node, self) }.include?(false) end # Returns the survey to the question def survey if node_map = self.node_maps.first node_map.survey end end # Build an answer off this node def build_answer(answer_node, survey = nil) survey = survey || self.node_maps.select { |i| !i.survey.nil? }.collect { |i| i.survey }.first # A survey must either be passed or already present in node_maps if survey.nil? raise ArgumentError.new "A survey must be passed if Question is not yet added to a survey" end # Answers actually define how they're built off the parent node... yep answer_node.build_answer(self, survey) end end end
Version data entries
8 entries across 8 versions & 1 rubygems