Sha256: 60d262d891cd6a3b8ad1af9d824d86ec87efffd1089a155ff282f5bea55f1aef

Contents?: true

Size: 666 Bytes

Versions: 11

Compression:

Stored size: 666 Bytes

Contents

module Martyr
  module Runtime
    module HasScopedLevels

      def scope(supported_level_ids)
        dup.scope!(supported_level_ids)
      end

      protected

      def scope!(supported_level_ids)
        @supported_level_ids = Array.wrap(supported_level_ids)
        @scoped_levels = nil
        self
      end

      private

      def scoped_levels
        return levels unless @supported_level_ids.present?
        return @scoped_levels if @scoped_levels
        unsupported_keys = levels.keys - @supported_level_ids
        supported_keys = levels.keys - unsupported_keys
        @scoped_levels = levels.slice(*supported_keys)
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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