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



307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/surveyor/parser.rb', line 307

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