Class: Effective::Response

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/response.rb

Instance Method Summary collapse

Instance Method Details

#category_partialObject



85
86
87
# File 'app/models/effective/response.rb', line 85

def category_partial
  question&.category_partial
end

#completed?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'app/models/effective/response.rb', line 89

def completed?
  responsable.try(:completed?) == true
end

#responseObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/models/effective/response.rb', line 65

def response
  return nil unless question.present?

  return date if question.date?
  return email if question.email?
  return number if question.number?
  return percentage if question.percentage?
  return price if question.price?
  return decimal if question.decimal?
  return long_answer if question.long_answer?
  return short_answer if question.short_answer?
  return upload_file if question.upload_file?

  return question_options.first if question.choose_one?
  return question_options.first if question.select_up_to_1?
  return question_options if question.question_option?

  raise('unknown response for unexpected question category')
end

#to_sObject



61
62
63
# File 'app/models/effective/response.rb', line 61

def to_s
  model_name.human || 'Response'
end