Sha256: 842616889dab55766e19a176ab1bdfa644e866f52c9639ee8aa760e7c3a4b981

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

module Martyr
  module Schema
    class LevelAssociation
      include Martyr::Level

      attr_accessor :level, :fact_key, :fact_alias, :sort
      alias_method :level_definition, :level

      # Important so that the to_i will take into account all levels defined for the dimension, not just the supported one
      delegate :to_i, to: :level

      delegate :label_key, :label_expression, to: :level

      # @param collection [LevelAssociationCollection]
      # @param level [BaseLevelDefinition]
      def initialize(collection, level, fact_key: nil, fact_alias: nil, sort: nil)
        @collection = collection
        @level = level
        @fact_key = fact_key || level.fact_key
        @fact_alias = fact_alias || level.fact_alias
        @sort = sort || level.sort
      end

      def supported?
        true
      end

      private

      # Delegate everything to level
      def method_missing(method_name, *args, &block)
        level.respond_to?(method_name) ? level.send(method_name, *args, &block) : super
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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