Class: OracleCloud::Asset
- Inherits:
-
Object
- Object
- OracleCloud::Asset
show all
- Defined in:
- lib/oraclecloud/asset.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client, path) ⇒ Asset
Returns a new instance of Asset.
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/oraclecloud/asset.rb', line 22
def initialize(client, path)
@client = client
@asset_data = nil
@path = path
@container = path.split('/').first
local_init
validate!
fetch
end
|
Instance Attribute Details
#asset_data ⇒ Object
Returns the value of attribute asset_data.
20
21
22
|
# File 'lib/oraclecloud/asset.rb', line 20
def asset_data
@asset_data
end
|
#asset_type ⇒ Object
Returns the value of attribute asset_type.
20
21
22
|
# File 'lib/oraclecloud/asset.rb', line 20
def asset_type
@asset_type
end
|
#client ⇒ Object
Returns the value of attribute client.
20
21
22
|
# File 'lib/oraclecloud/asset.rb', line 20
def client
@client
end
|
#container ⇒ Object
Returns the value of attribute container.
20
21
22
|
# File 'lib/oraclecloud/asset.rb', line 20
def container
@container
end
|
#path ⇒ Object
Returns the value of attribute path.
20
21
22
|
# File 'lib/oraclecloud/asset.rb', line 20
def path
@path
end
|
Instance Method Details
#fetch ⇒ Object
Also known as:
refresh
43
44
45
|
# File 'lib/oraclecloud/asset.rb', line 43
def fetch
@asset_data = client.single_item(asset_type, path)
end
|
#full_name ⇒ Object
57
58
59
|
# File 'lib/oraclecloud/asset.rb', line 57
def full_name
"/Compute-#{client.identity_domain}/#{name_with_container}"
end
|
#id ⇒ Object
Also known as:
name
48
49
50
|
# File 'lib/oraclecloud/asset.rb', line 48
def id
asset_data['name'].split('/').last
end
|
#local_init ⇒ Object
34
35
36
37
|
# File 'lib/oraclecloud/asset.rb', line 34
def local_init
end
|
#name_with_container ⇒ Object
53
54
55
|
# File 'lib/oraclecloud/asset.rb', line 53
def name_with_container
"#{container}/#{id}"
end
|
#strip_identity_domain(name) ⇒ Object
61
62
63
|
# File 'lib/oraclecloud/asset.rb', line 61
def strip_identity_domain(name)
name.gsub("/Compute-#{client.identity_domain}/", '')
end
|
#validate! ⇒ Object
39
40
41
|
# File 'lib/oraclecloud/asset.rb', line 39
def validate!
raise "#{self.class} did not define an asset_type variable" if asset_type.nil?
end
|