Skip to content

Instantly share code, notes, and snippets.

@moretea
Created May 25, 2011 18:40
Show Gist options
  • Select an option

  • Save moretea/991601 to your computer and use it in GitHub Desktop.

Select an option

Save moretea/991601 to your computer and use it in GitHub Desktop.
class Result
include Mongoid::Document
include Mongoid::Timestamps
FIELD_NAMES = [:persoonlijk, :versie, :brainstorm, :brainstorm_time]
(1..80).each { |n| FIELD_NAMES << :"stroop_#{n}" }
(1..6).each { |n| FIELD_NAMES << :"tekst_check_q#{n}" }
(1..8).each { |n| FIELD_NAMES << :"likert-l#{n}" }
(1..9).each { |n| FIELD_NAMES << :"likert-exit_b#{n}" }
(1..9).each { |n| FIELD_NAMES << :"likert-exit_t#{n}" }
(1..8).each { |n| FIELD_NAMES << :"exit_check#{n}" }
(1..8).each { |n| FIELD_NAMES << :"exit_check#{n}" }
WHERES = FIELD_NAMES.map { |field_name| {field_name.exists => true}}.reduce({}) { |a, b| a.merge(b) }
scope :completed, where(WHERES)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment