Class: ActiveRecordSurvey::Node::Question
- Inherits:
-
ActiveRecordSurvey::Node
- Object
- ActiveRecord::Base
- ActiveRecordSurvey::Node
- ActiveRecordSurvey::Node::Question
- Defined in:
- lib/active_record_survey/node/question.rb
Instance Method Summary collapse
-
#build_answer(answer_node) ⇒ Object
Build an answer off this node.
-
#validate_parent_instance_node(instance_node, child_node) ⇒ Object
Stop validating at the Question node.
Methods inherited from ActiveRecordSurvey::Node
#answers, #has_instance_node_for_instance?, #instance_node_for_instance, #instance_node_path_to_root?, #is_answered_for_instance?, #validate_instance_node
Instance Method Details
#build_answer(answer_node) ⇒ Object
Build an answer off this node
11 12 13 14 15 16 17 18 19 |
# File 'lib/active_record_survey/node/question.rb', line 11 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 Question is not yet added to a survey" end # Answers actually define how they're built off the parent node answer_node.send(:build_answer, self) end |
#validate_parent_instance_node(instance_node, child_node) ⇒ Object
Stop validating at the Question node
4 5 6 7 8 |
# File 'lib/active_record_survey/node/question.rb', line 4 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 |