Sha256: 8ea02e5e1635144a1030f3b0927d56e2aa88689ddd3283590c88bc2e3345f971

Contents?: true

Size: 649 Bytes

Versions: 5

Compression:

Stored size: 649 Bytes

Contents

require 'active_reporter/dimension/category'

module ActiveReporter
  module Dimension
    class Enum < Category
      def group_values
        return filter_values if filtering?

        # i = report.groupers.key(self)
        all_values & report.raw_data.keys.map { |x| x[0] }.uniq
      end

      def all_values
        enum_values.keys.unshift(nil)
      end

      private

      def enum_values
        model.defined_enums[attribute.to_s]
      end

      def sanitize_sql_value(value)
        enum_values.invert[value]
      end

      def enum?
        true # Hash(model&.defined_enums).include?(attribute.to_s)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
active_reporter-0.5.12 lib/active_reporter/dimension/enum.rb
active_reporter-0.5.11 lib/active_reporter/dimension/enum.rb
active_reporter-0.5.10 lib/active_reporter/dimension/enum.rb
active_reporter-0.5.9 lib/active_reporter/dimension/enum.rb
active_reporter-0.5.8 lib/active_reporter/dimension/enum.rb