Skip to content

Instantly share code, notes, and snippets.

@beck03076
Created November 23, 2016 23:17
Show Gist options
  • Save beck03076/96113f621f6369531f76a1e517f7aae1 to your computer and use it in GitHub Desktop.
Save beck03076/96113f621f6369531f76a1e517f7aae1 to your computer and use it in GitHub Desktop.
class SearchController
def search_repos
platform = Favorito::Platform.new(:github, { per_page: 10 })
client = Favorito::Client.create(platform)
client.repos('beck03076')
end
end
module Favorito
# ==================== Client ==============
class Client
class << self
def create(platform)
platform_klass::Client.new(platform.options)
end
private
def platform_klass
platform.name.to_s.classify.constantize
end
end
end
# ==================== PLatform ==============
class Platform
attr_accessor :name, :options
def initialize(name, opts = {})
@name = name
@options = opts
end
end
end
module Github
class Client
def self.repos(username)
end
end
end
module Bitbucket
class Client
def self.repos(username)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment