Class: MMS::Resource
- Inherits:
-
Object
show all
- Defined in:
- lib/mms/resource.rb
Defined Under Namespace
Classes: Alert, BackupConfig, Cluster, Group, Host, Metric, RestoreJob, Snapshot, SnapshotSchedule
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
8
9
10
|
# File 'lib/mms/resource.rb', line 8
def client
@client
end
|
#data ⇒ Object
Returns the value of attribute data.
6
7
8
|
# File 'lib/mms/resource.rb', line 6
def data
@data
end
|
#id ⇒ Object
Returns the value of attribute id.
5
6
7
|
# File 'lib/mms/resource.rb', line 5
def id
@id
end
|
Class Method Details
.find(client, *arguments) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/mms/resource.rb', line 70
def self.find(client, *arguments)
cache_key = self.cache_key(arguments.last())
data = MMS::Cache.instance.get(cache_key)
unless data
data = self._find(client, *arguments)
end
resource = self.new
resource.set_client(client)
resource.set_data(data)
resource
end
|
45
46
47
|
# File 'lib/mms/resource.rb', line 45
def self.
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
Instance Method Details
#_from_hash(data) ⇒ Object
54
55
56
|
# File 'lib/mms/resource.rb', line 54
def _from_hash(data)
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#_load(id) ⇒ Object
49
50
51
|
# File 'lib/mms/resource.rb', line 49
def _load(id)
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#_to_hash ⇒ Hash
59
60
61
|
# File 'lib/mms/resource.rb', line 59
def _to_hash
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#from_hash(data) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/mms/resource.rb', line 23
def from_hash(data)
unless data.nil?
@id = data['id']
_from_hash data
end
end
|
#invalidate_cache ⇒ Object
63
64
65
|
# File 'lib/mms/resource.rb', line 63
def invalidate_cache
MMS::Cache.instance.delete(cache_key(@id))
end
|
#set_client(client) ⇒ Object
11
12
13
|
# File 'lib/mms/resource.rb', line 11
def set_client(client)
@client = client
end
|
#set_data(data) ⇒ Object
16
17
18
19
20
|
# File 'lib/mms/resource.rb', line 16
def set_data(data)
@data = data
from_hash(data)
MMS::Cache.instance.set(cache_key(@id), data)
end
|
#table_row ⇒ Array<String>
35
36
37
|
# File 'lib/mms/resource.rb', line 35
def table_row
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#table_section ⇒ Array
40
41
42
|
# File 'lib/mms/resource.rb', line 40
def table_section
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#to_hash ⇒ Object
30
31
32
|
# File 'lib/mms/resource.rb', line 30
def to_hash
_to_hash
end
|