Skip to content

Instantly share code, notes, and snippets.

@alexandru-calinoiu
Last active January 10, 2017 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandru-calinoiu/19cd9e3d6f4c327d80b0132cfe795abb to your computer and use it in GitHub Desktop.
Save alexandru-calinoiu/19cd9e3d6f4c327d80b0132cfe795abb to your computer and use it in GitHub Desktop.
class VideoPresenter
def initialize(db_video, facebook_video)
@facebook_id = db_video[:id]
@age = facebook_video[:age]
end
end
db_videos = [{ id: 42, name: 'Ion' }, { id: 43, name: 'Gheo' }]
facebook_videos = [{ facebook_id: 43, age: 42 }, { facebook_id: 44, age: 43 }]
Tuplet = Struct.new(:db, :facebook)
p db_videos
.map { |db_video| Tuplet.new(db_video, facebook_videos.find { |h| h[:facebook_id] == db_video[:id] }) }
.keep_if(&:facebook)
.map { |tuplet| VideoPresenter.new(*tuplet) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment