Skip to content

Instantly share code, notes, and snippets.

@paulingham
Created December 30, 2010 22:40
Show Gist options
  • Save paulingham/760431 to your computer and use it in GitHub Desktop.
Save paulingham/760431 to your computer and use it in GitHub Desktop.
module GoggleBox
require 'httparty'
autoload :TVRage, 'goggle-box/tvrage.rb'
autoload :TheTVDB, 'goggle-box/thetvdb.rb'
class << self
attr_accessor :adapter
def adapter
@adapter ||= GoggleBox::TVRage
end
end
end
###
Got the above, and I can do;
>> GoggleBox.adapter
=> GoggleBox::TVRage
and..
>> GoggleBox.adapter = GoggleBox::TheTVDB
=> GoggleBox::TheTVDB
However, upon change of the adapter, I need to include that adapter module, which includes a Show and Episode class.
What's the best way?
I can add include @adapter underneath @adapter ||= GoggleBox::TVRage but then I get an adapter set of 'GoggleBox', with Show.search etc include - seems hacky though?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment