Created
October 13, 2016 10:34
-
-
Save royzinn/5c80cbd03589ebe34bd9ad6df925fd5c 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 FlightManager | |
def self.search(search_criteria) | |
flights = "FlightProviders::#{search_criteria[:provider].camelize}".constantize.search_flights search_criteria | |
normalize_flights flights | |
end | |
def self.normalize_flights(flights_arr) | |
## f here is a hash (each provider from above returns different hash | |
## need to turn f into an object so that can define/invoke "normalizing" methods on it | |
flights_arr.map do |f| | |
{ | |
origin_city: f.origin_city, | |
dest_city: f.dest_city, | |
... | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment