Skip to content

Instantly share code, notes, and snippets.

@dgorodnichy
Last active February 7, 2020 15:34
Show Gist options
  • Save dgorodnichy/e4d28d758b08eb95037b7e8960ececdd to your computer and use it in GitHub Desktop.
Save dgorodnichy/e4d28d758b08eb95037b7e8960ececdd to your computer and use it in GitHub Desktop.
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