-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add polymorphism to MetricSnapshot class
Removing if's in parent method and providing implementation in proper subclasses Signed-off-by: Pedro Ivo Andrade <[email protected]> Signed-off-by: Vitor Barbosa <[email protected]>
- Loading branch information
1 parent
3962d52
commit c2ac56f
Showing
5 changed files
with
107 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
class CompoundMetricSnapshot < MetricSnapshot | ||
def as_json(options = {}) | ||
# Type is considered by ActiveRecord as an implementation detail and so it is ignored by as_json | ||
# Here we set it, since it is important in our case | ||
json = super(options) | ||
json['type'] = 'CompoundMetricSnapshot' | ||
json.delete('metric_collector_name') | ||
json | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
class HotspotMetricSnapshot < NativeMetricSnapshot | ||
def as_json(options = {}) | ||
# Type is considered by ActiveRecord as an implementation detail and so it is ignored by as_json | ||
# Here we set it, since it is important in our case | ||
json = super(options) | ||
json['type'] = 'HotspotMetricSnapshot' | ||
json.delete('script') | ||
json | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
class NativeMetricSnapshot < MetricSnapshot | ||
def as_json(options = {}) | ||
# Type is considered by ActiveRecord as an implementation detail and so it is ignored by as_json | ||
# Here we set it, since it is important in our case | ||
json = super(options) | ||
json['type'] = 'NativeMetricSnapshot' | ||
json.delete('script') | ||
json | ||
end | ||
end |