Last active
February 7, 2020 15:34
-
-
Save dgorodnichy/e4d28d758b08eb95037b7e8960ececdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Posts | |
cattr_accessor :source | |
def initialize | |
@client = source.new | |
end | |
def posts(args) | |
@client.user_posts(args) | |
end | |
end | |
module PostsSources | |
class Medium | |
def initialize | |
@client = MediumApi.new(access_token) | |
end | |
def user_posts(args) | |
@client.posts(args) | |
end | |
end | |
end | |
module PostsSources | |
class Fake | |
def initialize | |
@client = OpenStruct.new( | |
posts: [{ | |
"title": "Liverpool FC", | |
"contentFormat": "html", | |
"content": "<h1>Liverpool FC</h1><p>You’ll never walk alone.</p>", | |
"canonicalUrl": "http://jamietalbot.com/posts/liverpool-fc", | |
"tags": ["football", "sport", "Liverpool"], | |
"publishStatus": "public" | |
}] | |
) | |
end | |
def user_posts(args) | |
@client.posts | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment