In my Rails app, I have two classes each with the same enum for status. Code climate is complaining about duplication.
class Enrolment < ActiveRecord::Base
has_many :enrolment_presentations
has_many :presentations, through: :enrolment_presentations
enum status: {
'Pending' => 1,
'Suspended' => 2,
'Cancelled' => 3,
'Pass' => 4,
'Fail' => 5,
'DPR' => 6,
'Unknown' => 7,
'Enrolled' => 8
}
end
class EnrolmentPresentations < ActiveRecord::Base
belongs_to :enrolment
belongs_to :presentation
enum status: {
'Pending' => 1,
'Suspended' => 2,
'Cancelled' => 3,
'Pass' => 4,
'Fail' => 5,
'DPR' => 6,
'Unknown' => 7,
'Enrolled' => 8
}
end
How would you go about removing this duplication?