tutor-server icon indicating copy to clipboard operation
tutor-server copied to clipboard

Reduce duplicated code in content module classes

Open thejourneydude opened this issue 10 years ago • 5 comments

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

thejourneydude avatar Jan 27 '16 16:01 thejourneydude

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?

nathanstitt avatar Jan 27 '16 16:01 nathanstitt

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

thejourneydude avatar Jan 27 '16 16:01 thejourneydude

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

nathanstitt avatar Jan 27 '16 22:01 nathanstitt

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

Dantemss avatar Jan 28 '16 16:01 Dantemss

Work on in sustain if no other bugs to fix.

jpslav avatar Mar 14 '16 17:03 jpslav