Sha256: 3c2514f73a0c4320ec217def3367ff3ea75103a489e806ec930f53c6aec61b04

Contents?: true

Size: 1.17 KB

Versions: 24

Compression:

Stored size: 1.17 KB

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_accessor :account

    def resource_via_client
      raise 'this method must be override!'
    end

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

    def inspect
      to_s
    end

    def self.tags_allowed
      define_method :has_tag? do |key, value|
        begin
          tags = resource_via_client.tags
        rescue NoMethodError
          tags = resource_via_client.tag_set
        end
        return false unless tags
        tags.any? { |t| t['key'] == key && t['value'] == value }
      end
    end

    def method_missing(name)
      name_str = name.to_s if name.class == Symbol
      describe = name_str.tr('-', '_').to_sym
      if !resource_via_client.nil? && 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

    undef :timeout
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
awspec-1.13.0 lib/awspec/type/base.rb
awspec-1.12.7 lib/awspec/type/base.rb
awspec-1.12.6 lib/awspec/type/base.rb
awspec-1.12.5 lib/awspec/type/base.rb
awspec-1.12.4 lib/awspec/type/base.rb
awspec-1.12.3 lib/awspec/type/base.rb
awspec-1.12.2 lib/awspec/type/base.rb
awspec-1.12.1 lib/awspec/type/base.rb
awspec-1.12.0 lib/awspec/type/base.rb
awspec-1.11.1 lib/awspec/type/base.rb
awspec-1.11.0 lib/awspec/type/base.rb
awspec-1.10.0 lib/awspec/type/base.rb
awspec-1.9.0 lib/awspec/type/base.rb
awspec-1.8.0 lib/awspec/type/base.rb
awspec-1.7.0 lib/awspec/type/base.rb
awspec-1.6.1 lib/awspec/type/base.rb
awspec-1.6.0 lib/awspec/type/base.rb
awspec-1.5.4 lib/awspec/type/base.rb
awspec-1.5.3 lib/awspec/type/base.rb
awspec-1.5.2 lib/awspec/type/base.rb