Class: AnalyticsOps::Snapshot
- Inherits:
-
Object
- Object
- AnalyticsOps::Snapshot
- Defined in:
- lib/analytics_ops/snapshot.rb,
sig/analytics_ops.rbs
Overview
Normalized remote state. No generated Google objects escape into this value.
Instance Attribute Summary collapse
-
#custom_dimensions ⇒ Array[Resources::CustomDimension]
readonly
Returns the value of attribute custom_dimensions.
-
#custom_metrics ⇒ Array[Resources::CustomMetric]
readonly
Returns the value of attribute custom_metrics.
-
#key_events ⇒ Array[Resources::KeyEvent]
readonly
Returns the value of attribute key_events.
-
#property ⇒ Resources::Property
readonly
Returns the value of attribute property.
-
#retention ⇒ Resources::Retention?
readonly
Returns the value of attribute retention.
-
#streams ⇒ Array[Resources::DataStream]
readonly
Returns the value of attribute streams.
Instance Method Summary collapse
- #fingerprint ⇒ String
-
#initialize(property:, streams:, retention:, key_events:, custom_dimensions:, custom_metrics:) ⇒ Snapshot
constructor
A new instance of Snapshot.
- #property_id ⇒ String
- #to_h ⇒ record
Constructor Details
#initialize(property:, streams:, retention:, key_events:, custom_dimensions:, custom_metrics:) ⇒ Snapshot
Returns a new instance of Snapshot.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/analytics_ops/snapshot.rb', line 10 def initialize(property:, streams:, retention:, key_events:, custom_dimensions:, custom_metrics:) unless property.is_a?(Resources::Property) raise ArgumentError, "property must be an AnalyticsOps::Resources::Property" end unless retention.nil? || retention.is_a?(Resources::Retention) raise ArgumentError, "retention must be an AnalyticsOps::Resources::Retention or nil" end @property = property @streams = sorted_resources(streams, Resources::DataStream, "streams", &:id) @retention = retention @key_events = sorted_resources(key_events, Resources::KeyEvent, "key_events", &:event_name) @custom_dimensions = sorted_resources( custom_dimensions, Resources::CustomDimension, "custom_dimensions" ) do |item| [item.scope, item.parameter_name] end @custom_metrics = sorted_resources(custom_metrics, Resources::CustomMetric, "custom_metrics", &:parameter_name) freeze end |
Instance Attribute Details
#custom_dimensions ⇒ Array[Resources::CustomDimension] (readonly)
Returns the value of attribute custom_dimensions.
8 9 10 |
# File 'lib/analytics_ops/snapshot.rb', line 8 def custom_dimensions @custom_dimensions end |
#custom_metrics ⇒ Array[Resources::CustomMetric] (readonly)
Returns the value of attribute custom_metrics.
8 9 10 |
# File 'lib/analytics_ops/snapshot.rb', line 8 def custom_metrics @custom_metrics end |
#key_events ⇒ Array[Resources::KeyEvent] (readonly)
Returns the value of attribute key_events.
8 9 10 |
# File 'lib/analytics_ops/snapshot.rb', line 8 def key_events @key_events end |
#property ⇒ Resources::Property (readonly)
Returns the value of attribute property.
8 9 10 |
# File 'lib/analytics_ops/snapshot.rb', line 8 def property @property end |
#retention ⇒ Resources::Retention? (readonly)
Returns the value of attribute retention.
8 9 10 |
# File 'lib/analytics_ops/snapshot.rb', line 8 def retention @retention end |
#streams ⇒ Array[Resources::DataStream] (readonly)
Returns the value of attribute streams.
8 9 10 |
# File 'lib/analytics_ops/snapshot.rb', line 8 def streams @streams end |
Instance Method Details
#fingerprint ⇒ String
46 47 48 |
# File 'lib/analytics_ops/snapshot.rb', line 46 def fingerprint Canonical.fingerprint(to_h) end |
#property_id ⇒ String
31 32 33 |
# File 'lib/analytics_ops/snapshot.rb', line 31 def property_id property.id end |
#to_h ⇒ record
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/analytics_ops/snapshot.rb', line 35 def to_h { "property" => property.to_h, "streams" => streams.map(&:to_h), "retention" => retention&.to_h, "key_events" => key_events.map(&:to_h), "custom_dimensions" => custom_dimensions.map(&:to_h), "custom_metrics" => custom_metrics.map(&:to_h) } end |