openstax / tutor-server

:mortar_board:
Other
15 stars 8 forks source link

Reduce duplicated code in content module classes #956

Open thejourneydude opened 8 years ago

thejourneydude commented 8 years ago

Browsing through code and I spotted nearly duplicated methods inside some of the content module classes. Could meta programming be implemented in this case? Maybe that's overkill and/or be super low-priority. Just thought I would throw in my two cents.

Reference: https://github.com/openstax/tutor-server/blob/50b622fb63f7dc26567f868a2828b5c29d5a206d/app/subsystems/content/exercise.rb

nathanstitt commented 8 years ago

Yep, we've got the wrap_attributes method that accomplishes that. https://github.com/openstax/tutor-server/blob/master/lib/wrapper.rb#L41-L53 It's used in: https://github.com/openstax/tutor-server/blob/master/app/subsystems/catalog/offering.rb#L8-L10

I'm guessing the code you spotted pre-dates the wrapper method or maybe it didn't work with it for some reason?

thejourneydude commented 8 years ago

I was about to go look over at the Wrapper class. Thanks! Super new to the code so my apologizes.

nathanstitt commented 8 years ago

Oh no worries at all! I wrote the wrapper but it looks like the instance I linked to is the only user of it :)

Dantemss commented 8 years ago

This would prob be a nice cleanup task for when you feel bored :)

jpslav commented 8 years ago

Work on in sustain if no other bugs to fix.