I'd like to find a way to do what this method does in a cleaner, less hacky looking way
def self.create_from_person!(person)
spi = new(:person => person, :provider => person.provider)
spi.age_eligible_code = participant.age_eligible?(person) ? 1 : 2
spi.county_of_residence_code = participant.psu_county_eligible?(person) ? 1 : 2
spi.first_prenatal_visit_code = participant.first_visit?(person) ? 1 : 2
spi.pregnancy_eligible_code = participant.pbs_pregnant?(person) ? 1 : 2
spi.save!
end
Any thoughts?
participantcome from? – tokland Feb 8 at 16:21participantis from a different model. I have some doubt that the eligibility methods belong there instead of onPersonbut thats not directly related to the feature I am working on. In case your interested theParticipantmodel and the rest of the project is here I like the refactoring below and I'm thinking about submitting it as part of my commit, if thats okay with you – steve_gallagher Feb 8 at 16:26participantdefined. To be called from a classmethod it should be a classmethod as well, but with that name it doesn't look like one. – tokland Feb 8 at 16:42participant = person.participant. Thanks. – steve_gallagher Feb 8 at 17:23