Sha256: d7777b22d8203d7b1400edcdfb937162efb99f2997d30f90b644446448010150

Contents?: true

Size: 1.15 KB

Versions: 50

Compression:

Stored size: 1.15 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
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
awspec-0.84.1 lib/awspec/type/base.rb
awspec-0.84.0 lib/awspec/type/base.rb
awspec-0.83.0 lib/awspec/type/base.rb
awspec-0.82.3 lib/awspec/type/base.rb
awspec-0.82.2 lib/awspec/type/base.rb
awspec-0.82.1 lib/awspec/type/base.rb
awspec-0.82.0 lib/awspec/type/base.rb
awspec-0.81.1 lib/awspec/type/base.rb
awspec-0.81.0 lib/awspec/type/base.rb
awspec-0.80.1 lib/awspec/type/base.rb
awspec-0.80.0 lib/awspec/type/base.rb
awspec-0.79.2 lib/awspec/type/base.rb
awspec-0.79.1 lib/awspec/type/base.rb
awspec-0.79.0 lib/awspec/type/base.rb
awspec-0.78.1 lib/awspec/type/base.rb
awspec-0.77.1 lib/awspec/type/base.rb
awspec-0.77.0 lib/awspec/type/base.rb
awspec-0.76.1 lib/awspec/type/base.rb
awspec-0.76.0 lib/awspec/type/base.rb
awspec-0.75.2 lib/awspec/type/base.rb