Created
March 23, 2012 05:44
-
-
Save cantremember/2167338 to your computer and use it in GitHub Desktop.
SOAPHelper for amazon-ec2 gem
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 SOAPHelper | |
class << self | |
def data_from(data, wrapper) | |
data[wrapper] || data | |
end | |
def items_from(set) | |
unless set && set.item | |
nil | |
else | |
items = set.item | |
items = [items] unless Array === items | |
items | |
end | |
end | |
end | |
end | |
data = SOAPHelper.data_from( | |
@ec2.describe_instances, | |
'DescribeInstancesResponse' | |
) | |
reservations = SOAPHelper.items_from(data.reservationSet) || [] | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment