Sha256: c334019b9ca0eb9d6d1dc384183d558f666dd1c7da720c7d056b871cd519f204

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

module Martyr
  module Schema
    class BaseLevelDefinition
      include ActiveModel::Model
      include Martyr::Level

      # @attribute fact_key [String] the field in the fact where the attribute resides. E.g.:
      #   degenerate_level :country, fact_key: 'invoices.country'
      #
      # @attribute fact_alias [String] the alias to give in the `AS` part of the SQL fact statement.
      #
      # @attribute sort [Proc] optional lambda function for sorting.
      #   For query levels it accepts the record:
      #     ->(record) { record.custom_sort_order }
      #
      #   For degenerates it accepts the value:
      #     ->(value) { value[1..2] }
      #
      attr_accessor :name, :fact_key, :fact_alias, :sort

      delegate :dimension_name, :dimension_definition, to: :collection
      alias_method :slice_id, :dimension_name
      delegate :build_data_slice, :build_memory_slice, to: :dimension_definition

      # This allows to ask any Martyr::Level for #level_definition
      def level_definition
        self
      end

      def dimension_definition
        collection.dimension
      end

      def supported?
        false
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
martyr-0.1.85.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.84.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.82.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.81.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.80.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.79.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.78.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.77.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.76.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.75.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb
martyr-0.1.74.pre lib/martyr/schema/plain_dimension_levels/base_level_definition.rb