Module: SurveyorParserSurveyMethods

Defined in:
lib/surveyor/parser.rb

Overview

Survey model

Instance Method Summary collapse

Instance Method Details

#clear(context) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/surveyor/parser.rb', line 175

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



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

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