Sha256: 8095c32fd1e04e2406c5839bbb426dbd42cebea368de7b1e20ae97e3c98356b2

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

module Martyr
  module Runtime
    class QueryMetrics < HashWithIndifferentAccess
      include Martyr::Registrable
      include Martyr::Translations

      attr_reader :sub_cube

      delegate :cube, to: :sub_cube

      include Martyr::Delegators
      each_child_delegator :add_to_select, to: :values

      alias_method :find_metric, :find_or_error

      def initialize(sub_cube)
        @sub_cube = sub_cube
      end

      def inspect
        "#<#{self.class} #{to_a}>"
      end

      def to_a
        keys
      end

      def add_metric(metric_id)
        with_standard_id(metric_id) do |cube_name, metric_name|
          register cube.find_metric(metric_name) if cube_name == sub_cube.cube_name
        end
      end

      def built_in_metrics
        values.select{|x| x.is_a?(Schema::BuiltInMetric)}
      end

      def custom_metrics
        values.select{|x| x.is_a?(Schema::CustomMetric)}
      end

      def custom_rollups
        values.select{|x| x.is_a?(Schema::CustomRollup)}
      end

      def metric_ids
        values.map(&:id)
      end

      def metric_objects
        values
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
martyr-0.1.85.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.84.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.82.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.81.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.80.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.79.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.78.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.77.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.76.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.75.pre lib/martyr/runtime/sub_cubes/query_metrics.rb
martyr-0.1.74.pre lib/martyr/runtime/sub_cubes/query_metrics.rb