Sha256: c266ca64a97d73ba2c8d2b3c50f6b53073c1b0a6323ff5fec569171ff56974f6

Contents?: true

Size: 591 Bytes

Versions: 8

Compression:

Stored size: 591 Bytes

Contents

module NxtRegistry
  class RecursiveRegistry < Registry
    def initialize(name, **options, &config)
      @level = options.fetch(:level) { 0 }

      @name = name
      @options = options
      @config = config

      super(name, **options, &config)
      set_nested_builder_as_default
    end

    attr_reader :name

    private

    attr_reader :options, :config, :level

    def set_nested_builder_as_default
      self.default = NestedRegistryBuilder.new do
        RecursiveRegistry.new("level_#{(level + 1)}", **options.merge(level: (level + 1)), &config)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nxt_registry-0.2.1 lib/nxt_registry/recursive_registry.rb
nxt_registry-0.2.0 lib/nxt_registry/recursive_registry.rb
nxt_registry-0.1.5 lib/nxt_registry/recursive_registry.rb
nxt_registry-0.1.4 lib/nxt_registry/recursive_registry.rb
nxt_registry-0.1.3 lib/nxt_registry/recursive_registry.rb
nxt_registry-0.1.2 lib/nxt_registry/recursive_registry.rb
nxt_registry-0.1.1 lib/nxt_registry/recursive_registry.rb
nxt_registry-0.1.0 lib/nxt_registry/recursive_registry.rb