Sha256: ad559aa5ed84fb3b57b0603afe641c6c1d82026b7a73a75ac273d1ea7f63f6d4

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

require 'aws-sdk'
require 'awspec/resource_reader'
require 'awspec/helper/finder'

module Awspec::Type
  class Base
    include Awspec::Helper::Finder
    include Awspec::BlackListForwardable

    attr_reader :id, :resource_via_client

    def initialize(id = nil)
      @display_name = id
      super
      @id = nil
    end

    def to_s
      type = self.class.name.demodulize.underscore
      "#{type} '#{@display_name}'"
    end

    def inspect
      to_s
    end

    def exists?
      @id
    end

    def method_missing(name)
      describe = name.to_sym
      if @resource_via_client.members.include?(describe)
        @resource_via_client[describe]
      else
        super unless self.respond_to?(:resource)
        method_missing_via_black_list(name, delegate_to: resource)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
awspec-0.26.2 lib/awspec/type/base.rb
awspec-0.26.1 lib/awspec/type/base.rb