Sha256: 2f84eb2c97e813bde84b694fc5c63d9f67bed79999d8d13069092074c59ab6a6

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'avm/registry/application_stereotypes/stereotype_builder'
require 'eac_ruby_utils/core_ext'

module Avm
  module Registry
    class ApplicationStereotypes
      class BuildAvailable
        enable_method_class

        common_constructor :owner

        def result
          reset_buffer
          read_instances_registry
          read_sources_registry
          buffer.values.map(&:build)
        end

        private

        attr_accessor :buffer

        def read_object(type, object)
          buffer[object.stereotype_namespace_module] ||=
            ::Avm::Registry::ApplicationStereotypes::StereotypeBuilder
              .new(object.stereotype_namespace_module)
          buffer[object.stereotype_namespace_module].add_object(type, object)
        end

        def read_instances_registry
          ::Avm::Registry.instances.available.each { |instance| read_object(:instance, instance) }
        end

        def read_sources_registry
          ::Avm::Registry.sources.available.each { |source| read_object(:source, source) }
        end

        def reset_buffer
          self.buffer = {}
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
eac_tools-0.11.1 sub/avm/lib/avm/registry/application_stereotypes/build_available.rb
avm-0.29.0 lib/avm/registry/application_stereotypes/build_available.rb
eac_tools-0.11.0 sub/avm/lib/avm/registry/application_stereotypes/build_available.rb
avm-0.28.0 lib/avm/registry/application_stereotypes/build_available.rb
eac_tools-0.10.0 sub/avm/lib/avm/registry/application_stereotypes/build_available.rb
avm-0.27.0 lib/avm/registry/application_stereotypes/build_available.rb
eac_tools-0.9.0 sub/avm/lib/avm/registry/application_stereotypes/build_available.rb