Module: StudySubjectInterviews

Included in:
StudySubject
Defined in:
app/models/study_subject_interviews.rb

Overview

Simply extracted some code to clean up model. I’d like to do this to all of the really big classes but let’s see how this goes first.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/study_subject_interviews.rb', line 7

def self.included(base)
#	Must delay the calls to these ActiveRecord methods
#	or it will raise many "undefined method"s.
base.class_eval do

	has_many :interviews

	#	Returns home exposures interview
	def hx_interview
		interviews.find(:first,
#			:conditions => "projects.key = 'HomeExposures'",
			:conditions => { 'projects.id' => Project['HomeExposures'].id },
			:joins => [:instrument_version => [:instrument => :project]]
		)
	end

end	#	class_eval
end