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



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

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 = PermittedParams.new({
    :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_/, "") })).dependency_condition
  context[:dependency].dependency_conditions << context[:dependency_condition] = self
  context[:dependency_conditions] << self
end