Last active
January 10, 2017 14:06
-
-
Save alexandru-calinoiu/19cd9e3d6f4c327d80b0132cfe795abb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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