Sha256: d59a0be09e707e1540d0c6e077687dd5f42180a7d25ba3c9a4f897bcb6af5596

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module Awspec::Type
  class RouteTable < Base
    def initialize(id)
      super
      @resource = find_route_table(id)
      @id = @resource[:route_table_id] if @resource
    end

    def has_route?(destination, gateway_id = nil, instance_id = nil)
      @resource.routes.find do |route|
        if destination
          next false unless route.destination_cidr_block == destination
        end
        # * gateway
        next true if route.gateway_id == gateway_id
        # internet gateway
        igw = find_internet_gateway(gateway_id)
        next true if igw && igw.tag_name == gateway_id
        # virtual gateway
        vgw = find_virtual_gateway(gateway_id)
        next true if vgw && vgw.tag_name == gateway_id
        # customer gateway
        cgw = find_customer_gateway(gateway_id)
        next true if cgw && cgw.tag_name == gateway_id
        # instance
        next true if route.instance_id == instance_id
        instance = find_ec2(instance_id)
        next true if instance && instance.tag_name == instance_id
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
awspec-0.21.2 lib/awspec/type/route_table.rb
awspec-0.21.1 lib/awspec/type/route_table.rb
awspec-0.21.0 lib/awspec/type/route_table.rb