Class: Decidim::MetricManifest

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, AttributeObject::Model
Defined in:
lib/decidim/metric_manifest.rb

Overview

This class acts as a manifest for metrics.

This manifest is a simple object that holds and stores currently available metrics and its managers, for calculations purpose

Direct Known Subclasses

MetricOperationManifest

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Method Summary collapse

Methods included from AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#has_settings?Boolean

Returns:



18
19
20
# File 'lib/decidim/metric_manifest.rb', line 18

def has_settings?
  settings.attributes.any?
end

#settings {|@settings| ... } ⇒ Object

Yields:



22
23
24
25
26
# File 'lib/decidim/metric_manifest.rb', line 22

def settings(&block)
  @settings ||= SettingsManifest.new
  yield(@settings) if block
  @settings
end

#stat_blockObject

stat_block is a non-required parameter This method make it easier to retrieve it,

and gives an empty string if it's not configured


31
32
33
# File 'lib/decidim/metric_manifest.rb', line 31

def stat_block
  settings.attributes[:stat_block].try(:[], :default) || ""
end