Last active
August 29, 2015 14:27
-
-
Save luxflux/42e9cdc92892c21dcbda 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 MappingTest | |
MAPPING = { | |
passengers: ->(hash) { hash[:customer_info][:person_name] }, | |
flight_ticket_selling_carrier: :extract_services, | |
} | |
def results | |
response = api_call | |
res = {} | |
MAPPING.each do |attribute, extraction| | |
res[attribute] = if extraction.respond_to?(:call) | |
extraction.call(response) # call proc or lambda | |
else | |
send(response) # call method defined on the class | |
end | |
end | |
res | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment