Module: SurveyorRedcapParserSurveySectionMethods

Defined in:
lib/surveyor/redcap_parser.rb

Overview

SurveySection model

Instance Method Summary collapse

Instance Method Details

#build_or_set(context, r) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/surveyor/redcap_parser.rb', line 86

def build_or_set(context, r)
  unless context[:survey_section] && context[:survey_section].reference_identifier == r[:form_name]
    if match = context[:survey].sections.detect{|ss| ss.reference_identifier == r[:form_name]}
      context[:current_survey_section] = match
    else
      self.attributes = (
        {:title => r[:form_name].to_s.humanize,
        :reference_identifier => r[:form_name],
        :display_order => context[:survey].sections.size })
      context[:survey].sections << context[:survey_section] = self
      Surveyor::RedcapParser.rake_trace "survey_section_#{context[:survey_section].reference_identifier} "
    end
  end
end