Class: Google::Storage::Data::BucketNameRefCatalog

Inherits:
BucketNameRef
  • Object
show all
Defined in:
lib/google/storage/property/bucket_name.rb

Overview

A class to fetch the resource value from a referenced block Will return the value exported from a different Puppet resource

Instance Method Summary collapse

Methods inherited from BucketNameRef

#<=>, #==

Constructor Details

#initialize(title, resource) ⇒ BucketNameRefCatalog

Returns a new instance of BucketNameRefCatalog.



53
54
55
56
# File 'lib/google/storage/property/bucket_name.rb', line 53

def initialize(title, resource)
  @title = title
  @resource = resource
end

Instance Method Details

#autorequiresObject

Puppet requires the title for autorequiring



59
60
61
# File 'lib/google/storage/property/bucket_name.rb', line 59

def autorequires
  [@title]
end

#resourceObject

Raises:

  • (ArgumentError)


72
73
74
75
76
77
# File 'lib/google/storage/property/bucket_name.rb', line 72

def resource
  Google::ObjectStore.instance[:gstorage_bucket].each do |entry|
    return entry.exports[:name] if entry.title == @title
  end
  raise ArgumentError, "gstorage_bucket[#{@title}] required"
end

#to_json(_arg = nil) ⇒ Object



67
68
69
70
# File 'lib/google/storage/property/bucket_name.rb', line 67

def to_json(_arg = nil)
  return if resource.nil?
  resource.to_json
end

#to_sObject



63
64
65
# File 'lib/google/storage/property/bucket_name.rb', line 63

def to_s
  resource.to_s
end