You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
525 B
32 lines
525 B
3 years ago
|
# frozen_string_literal: true
|
||
|
|
||
|
class Admin::Metrics::Dimension::BaseDimension
|
||
|
def initialize(start_at, end_at, limit)
|
||
|
@start_at = start_at&.to_datetime
|
||
|
@end_at = end_at&.to_datetime
|
||
|
@limit = limit&.to_i
|
||
|
end
|
||
|
|
||
|
def key
|
||
|
raise NotImplementedError
|
||
|
end
|
||
|
|
||
|
def data
|
||
|
raise NotImplementedError
|
||
|
end
|
||
|
|
||
|
def self.model_name
|
||
|
self.class.name
|
||
|
end
|
||
|
|
||
|
def read_attribute_for_serialization(key)
|
||
|
send(key) if respond_to?(key)
|
||
|
end
|
||
|
|
||
|
protected
|
||
|
|
||
|
def time_period
|
||
|
(@start_at...@end_at)
|
||
|
end
|
||
|
end
|