Sha256: c4cc1e809e394df6a2b685337f34c7c904684c6ed009f9ca94626becceb5f4f3

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

module Berkshelf::API
  module Mixin
    module Services
      class << self
        def included(base)
          base.extend(ClassMethods)
          base.send(:include, ClassMethods)
        end

        def extended(base)
          base.send(:include, ClassMethods)
        end
      end

      module ClassMethods
        # @raise [Berkshelf::API::NotStartedError] if the cache manager has not been started
        #
        # @return [Berkshelf::API::CacheBuilder]
        def cache_builder
          app_actor(:cache_builder)
        end

        # @raise [Berkshelf::API::NotStartedError] if the cache manager has not been started
        #
        # @return [Berkshelf::API::CacheManager]
        def cache_manager
          app_actor(:cache_manager)
        end

        # @raise [Berkshelf::API::NotStartedError] if the rest gateway has not been started
        #
        # @return [Berkshelf::API::RESTGateway]
        def rest_gateway
          app_actor(:rest_gateway)
        end

        private

          def app_actor(id)
            unless Application[id] && Application[id].alive?
              raise NotStartedError, "#{id} not running"
            end
            Application[id]
          end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
berkshelf-api-3.0.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-2.2.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-2.1.3 lib/berkshelf/api/mixin/services.rb
berkshelf-api-2.1.2 lib/berkshelf/api/mixin/services.rb
berkshelf-api-2.1.1 lib/berkshelf/api/mixin/services.rb
berkshelf-api-2.1.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-2.0.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.4.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.3.1 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.3.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.2.2 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.2.1 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.2.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.2.0.rc2 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.2.0.rc1 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.1.1 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.1.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-1.0.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-0.2.0 lib/berkshelf/api/mixin/services.rb
berkshelf-api-0.1.0 lib/berkshelf/api/mixin/services.rb