Skip to content

Instantly share code, notes, and snippets.

@royzinn
Created October 13, 2016 10:34
Show Gist options
  • Save royzinn/5c80cbd03589ebe34bd9ad6df925fd5c to your computer and use it in GitHub Desktop.
Save royzinn/5c80cbd03589ebe34bd9ad6df925fd5c to your computer and use it in GitHub Desktop.
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