Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/surveyor/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ def parse(str)
# This method_missing does all the heavy lifting for the DSL
def method_missing(missing_method, *args, &block)
method_name, reference_identifier = missing_method.to_s.split("_", 2)

# Quick fix to allow validations and dependencies on a single question.
if method_name == 'validation'
context[:last] = 'validation'
elsif method_name == 'dependency'
context[:last] = 'dependency'
end

type = full(method_name)
Surveyor::Parser.raise_error( "\"#{type}\" is not a surveyor method." )if !%w(survey survey_translation survey_section question_group question dependency dependency_condition answer validation validation_condition).include?(type)

Expand Down Expand Up @@ -113,7 +121,7 @@ def full(method_name)
when /^q$|^label$|^image$/; "question"
when /^a$/; "answer"
when /^d$/; "dependency"
when /^c(ondition)?$/; context[:validation] ? "validation_condition" : "dependency_condition"
when /^c(ondition)?$/; context[:last] == 'validation' ? "validation_condition" : "dependency_condition"
when /^v$/; "validation"
when /^dc(ondition)?$/; "dependency_condition"
when /^vc(ondition)?$/; "validation_condition"
Expand Down