class Awspec::Type::Base

Attributes

account[RW]

Public Class Methods

tags_allowed() click to toggle source
# File lib/awspec/type/base.rb, line 29
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

Public Instance Methods

inspect() click to toggle source
# File lib/awspec/type/base.rb, line 21
def inspect
  to_s
end
method_missing(name) click to toggle source
Calls superclass method
# File lib/awspec/type/base.rb, line 41
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]
  elsif resource_via_client.nil?
    raise Awspec::NoExistingResource.new(self.class, @display_name)
  else
    super unless self.respond_to?(:resource)
    method_missing_via_black_list(name, delegate_to: resource)
  end
end
resource_via_client() click to toggle source
# File lib/awspec/type/base.rb, line 12
def resource_via_client
  raise 'this method must be override!'
end
respond_to_missing?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/awspec/type/base.rb, line 25
def respond_to_missing?(method, include_private = false)
  resource_via_client.respond_to?(method) || super unless resource_via_client.nil?
end
to_s() click to toggle source
# File lib/awspec/type/base.rb, line 16
def to_s
  type = self.class.name.demodulize.underscore
  "#{type} '#{@display_name}'"
end

Private Instance Methods

check_existence() click to toggle source
# File lib/awspec/type/base.rb, line 59
def check_existence
  raise Awspec::NoExistingResource.new(self.class, @display_name) if resource_via_client.nil?
end