Class: MMS::Resource
- Inherits:
-
Object
show all
- Defined in:
- lib/mms/resource.rb
Defined Under Namespace
Classes: Alert, Cluster, Group, Host, 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
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/mms/resource.rb', line 67
def self.find(client, *arguments)
cache_key = "Class::#{self.name}:#{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
|
46
47
48
|
# File 'lib/mms/resource.rb', line 46
def self.
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
Instance Method Details
#_from_hash(data) ⇒ Object
55
56
57
|
# File 'lib/mms/resource.rb', line 55
def _from_hash(data)
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#_load(id) ⇒ Object
50
51
52
|
# File 'lib/mms/resource.rb', line 50
def _load(id)
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#_to_hash ⇒ Hash
60
61
62
|
# File 'lib/mms/resource.rb', line 60
def _to_hash
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#from_hash(data) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/mms/resource.rb', line 24
def from_hash(data)
unless data.nil?
@id = data['id']
_from_hash data
end
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
21
|
# File 'lib/mms/resource.rb', line 16
def set_data(data)
@data = data
from_hash(data)
cache_key = "Class::#{self.class.name}:#{@id}"
MMS::Cache.instance.set(cache_key, data)
end
|
#table_row ⇒ Array<String>
36
37
38
|
# File 'lib/mms/resource.rb', line 36
def table_row
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#table_section ⇒ Array
41
42
43
|
# File 'lib/mms/resource.rb', line 41
def table_section
raise("`#{__method__}` is not implemented for `#{self.class.name}`")
end
|
#to_hash ⇒ Object
31
32
33
|
# File 'lib/mms/resource.rb', line 31
def to_hash
_to_hash
end
|