Last active
December 22, 2015 18:49
-
-
Save lgrains/6515452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Seed | |
class CourseRequirement < OpenStruct | |
include Gardener | |
def self.destroyable? | |
true | |
end | |
def attributes | |
{ coming_soon: coming_soon } | |
end | |
def degree | |
::Degree.find_by(title: degree_title) | |
end | |
def target | |
::CourseRequirement.find_or_create_by( | |
degree_id: degree.id, | |
requirement_type: requirement_type, | |
title: requirement_title | |
) | |
end | |
def valid? | |
degree && fields | |
end | |
def fields | |
!(requirement_type.empty? || requirement_title.empty?) | |
end | |
def log_error | |
puts "Degree by title: #{degree_title} not found" unless degree | |
puts "CourseRequirement by title: #{requirement_title} and type: #{requirement_type} not found" unless target | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment