Module: SurveyorParserSurveyMethods

Defined in:
lib/surveyor/parser.rb

Overview

Survey model

Instance Method Summary collapse

Instance Method Details

#clear(context) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/surveyor/parser.rb', line 163

def clear(context)
  context.delete_if{|k,v| true}
  context.merge!({
    :question_references => {},
    :answer_references => {},
    :bad_references => [],
    :duplicate_references => [],
    :dependency_conditions => [],
    :questions_with_correct_answers => {},
    :default_mandatory => false
  })
end

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



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/surveyor/parser.rb', line 150

def parse_and_build(context, args, original_method, reference_identifier)
  # clear context
  clear(context)

  # build and set context
  title = args[0]
  args[1] ||= {}
  context[:default_mandatory] = args[1].delete(:default_mandatory) || false
  self.attributes = ({
    :title => title,
    :reference_identifier => reference_identifier }.merge(args[1]))
  context[:survey] = self
end