Class: SnapshotInspector::Snapshot::Type
- Inherits:
-
Object
- Object
- SnapshotInspector::Snapshot::Type
show all
- Defined in:
- app/models/snapshot_inspector/snapshot/type.rb
Defined Under Namespace
Classes: UnknownSnapshotee
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
12
13
14
15
16
|
# File 'app/models/snapshot_inspector/snapshot/type.rb', line 12
def self.(snapshotee)
record = type_class(snapshotee.class).new
record.(snapshotee)
record
end
|
.from_hash(hash) ⇒ Object
18
19
20
21
22
|
# File 'app/models/snapshot_inspector/snapshot/type.rb', line 18
def self.from_hash(hash)
record = type_class(hash[:snapshotee_class].constantize).new
record.from_hash(hash)
record
end
|
.snapshotee(class_name) ⇒ Object
8
9
10
|
# File 'app/models/snapshot_inspector/snapshot/type.rb', line 8
def self.snapshotee(class_name)
registry[class_name] = self
end
|
Instance Method Details
#as_json(data = {}) ⇒ Object
47
48
49
|
# File 'app/models/snapshot_inspector/snapshot/type.rb', line 47
def as_json(data = {})
{snapshotee_class: registry.key(self.class)}.merge(super)
end
|
34
35
36
|
# File 'app/models/snapshot_inspector/snapshot/type.rb', line 34
def (_snapshotee)
raise "Implement in a child class."
end
|
#from_hash(_hash) ⇒ Object
39
40
41
|
# File 'app/models/snapshot_inspector/snapshot/type.rb', line 39
def from_hash(_hash)
raise "Implement in a child class."
end
|
#type ⇒ Object
43
44
45
|
# File 'app/models/snapshot_inspector/snapshot/type.rb', line 43
def type
self.class.to_s.underscore.split("/").last.gsub("_type", "")
end
|