Sha256: 9865e704e72325d5380d8d3105e7c3ba210b63ecad8b399998443de580e98114

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require_relative './helper'
module CelluloidPubsub
  # base actor used for compatibility between celluloid versions
  module BaseActor

    class << self
      include Helper
      attr_reader :config

      def included(base)
        base.send(:include, Celluloid)
        base.send(:include, Celluloid::IO)
        base.send(:include, CelluloidPubsub::Helper)
        base.send(:include, config['logger_class'])
      end

      def config
        {
          'logger_class' => celluloid_logger_class
        }
      end

      def celluloid_logger_class
        if version_less_than_seventeen?
          Celluloid::Logger
        else
          Celluloid::Internals::Logger
        end
      end

      def celluloid_version
        find_loaded_gem_property('celluloid', 'version')
      end

      def version_less_than_seventeen?
        verify_gem_version(celluloid_version, '0.17', operator: '<')
      end

      def setup_actor_supervision(class_name, options)
        if version_less_than_seventeen?
          class_name.supervise_as(options[:actor_name], options[:args])
        else
          class_name.supervise(as: options[:actor_name], args: [options[:args]].compact)
        end
      end

    end
  end
end

if CelluloidPubsub::BaseActor.version_less_than_seventeen?
  require 'celluloid/autostart'
else
  require 'celluloid/current'
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
celluloid_pubsub-0.9.0 lib/celluloid_pubsub/base_actor.rb
celluloid_pubsub-0.8.4 lib/celluloid_pubsub/base_actor.rb
celluloid_pubsub-0.8.3 lib/celluloid_pubsub/base_actor.rb
celluloid_pubsub-0.8.2 lib/celluloid_pubsub/base_actor.rb
celluloid_pubsub-0.8.1 lib/celluloid_pubsub/base_actor.rb