Sha256: c8d602898a11839e50cb04b83657d1993871674ef8b7715ec9e1c88401109804

Contents?: true

Size: 785 Bytes

Versions: 6

Compression:

Stored size: 785 Bytes

Contents

module SurveyorGui
  module Helpers
    module SurveyorGuiHelperMethods
      # Responses
      def response_for(response_set, question, answer = nil, response_group = nil, column_id = nil)
        return nil unless response_set && question && question.id
        result = response_set.responses.detect{|r| 
          (r.question_id == question.id) && 
          (answer.blank? ? true : r.answer_id == answer.id) && 
          (r.response_group.blank? ? true : r.response_group.to_i == response_group.to_i) && 
          (r.column_id.blank? ? true : r.column_id == column_id.to_i)}
        result.blank? ? response_set.responses.build(
          question_id: question.id, 
          response_group: response_group, 
          column_id: column_id) : result
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
upgrade_surveyor_gui-0.1.3 lib/surveyor_gui/helpers/surveyor_helper_methods.rb
upgrade_surveyor_gui-0.1.2 lib/surveyor_gui/helpers/surveyor_helper_methods.rb
surveyor_gui-0.1.2 lib/surveyor_gui/helpers/surveyor_helper_methods.rb
surveyor_gui-0.1.1 lib/surveyor_gui/helpers/surveyor_helper_methods.rb
surveyor_gui-0.1.0 lib/surveyor_gui/helpers/surveyor_helper_methods.rb
surveyor_gui-0.0.3 lib/surveyor_gui/helpers/surveyor_helper_methods.rb