# File lib/aws/ec2/route_table.rb, line 66 def subnets subnets = associations.map(&:subnet) # The default route table has a single association where #subnet # returns nil (the main association). If this is not the main # route table we can safely return the subnets. return subnets unless subnets.include?(nil) subnets.compact! # This is the default route table and to get the complete list of # subnets we have to find all subnets without an association AWS.memoize do # every subnet all_subnets = vpc.subnets.to_a # subnets assigned directly to a route table associated_subnets = vpc.route_tables. map(&:associations).flatten. map(&:subnet).flatten. compact # subnets NOT assigned to a route table, these default as # belonging to the default route table through the "main" # association unassociated_subnets = all_subnets.inject([]) do |list,subnet| unless associated_subnets.include?(subnet) list << subnet end list end subnets + unassociated_subnets end end