Module: SurveyorParserDependencyConditionMethods

Defined in:
lib/surveyor/parser.rb

Overview

DependencyCondition model

Instance Method Summary collapse

Instance Method Details

#parse_and_build(context, args, original_method, reference_identifier) ⇒ Object



328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/surveyor/parser.rb', line 328

def parse_and_build(context, args, original_method, reference_identifier)
  # clear context
  context.delete :dependency_condition

  # build and set context
  a0, a1, a2 = args
  self.attributes = ({
    :operator => a1 || "==",
    :question_reference => a0.to_s.gsub(/^q_|^question_/, ""),
    :rule_key => reference_identifier
  }.merge( a2.is_a?(Hash) ? a2 : { :answer_reference => a2.to_s.gsub(/^a_|^answer_/, "") }))
  context[:dependency].dependency_conditions << context[:dependency_condition] = self
  context[:dependency_conditions] << self
end