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-1.4.1 lib/awspec/type/base.rb
awspec-1.4.0 lib/awspec/type/base.rb
awspec-1.3.1 lib/awspec/type/base.rb
awspec-1.3.0 lib/awspec/type/base.rb
awspec-1.2.0 lib/awspec/type/base.rb
awspec-1.1.0 lib/awspec/type/base.rb
awspec-1.0.0 lib/awspec/type/base.rb
awspec-1.0.0.rc lib/awspec/type/base.rb
awspec-0.88.2 lib/awspec/type/base.rb
awspec-0.88.1 lib/awspec/type/base.rb
awspec-0.88.0 lib/awspec/type/base.rb
awspec-0.87.1 lib/awspec/type/base.rb
awspec-0.87.0 lib/awspec/type/base.rb
awspec-0.86.0 lib/awspec/type/base.rb
cmonson_2ndwatch_awspec-0.85.4 lib/awspec/type/base.rb
awspec-0.85.3 lib/awspec/type/base.rb
cmonson_2ndwatch_awspec-0.85.3 lib/awspec/type/base.rb
awspec-0.85.2 lib/awspec/type/base.rb
awspec-0.85.1 lib/awspec/type/base.rb
awspec-0.85.0 lib/awspec/type/base.rb