Sha256: 0a432bd71085bb1614127e0e15f74faed90abae6b302ee78e2d438939669cdbf

Contents?: true

Size: 888 Bytes

Versions: 42

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EacDocker
  module Rspec
    class StubImage
      include ::ActiveSupport::Callbacks
      define_callbacks :on_container
      common_constructor :image

      def build_container
        image.provide.container.temporary(true)
      end

      def container
        raise 'internal container is blank' if internal_container.blank?

        internal_container
      end

      def on_container(&block)
        raise 'A container was already created' if internal_container.present?

        build_container.on_detached do |container|
          self.internal_container = container
          begin
            run_callbacks(:on_container, &block)
          ensure
            self.internal_container = nil
          end
        end
      end

      private

      attr_accessor :internal_container
    end
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
eac_tools-0.76.1 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.76.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.75.2 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.75.1 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.75.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.74.1 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.74.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.73.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.72.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.70.1 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.70.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.69.1 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.69.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.68.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.67.1 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.67.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.66.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.65.1 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.65.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb
eac_tools-0.64.0 sub/eac_docker/lib/eac_docker/rspec/stub_image.rb