module CelluloidPubsub::BaseActor

base actor used for compatibility between celluloid versions @!attribute [r] config

@return [Hash] The configuration classes and their aliases

Public Class Methods

boot_up() click to toggle source

tries to boot up Celluloid if it is not running @return [Boolean] returns true if Celluloid started false otherwise

@api public

# File lib/celluloid_pubsub/base_actor.rb, line 81
def boot_up
  celluloid_running = begin
    Celluloid.running?
  rescue StandardError
    false
  end
  Celluloid.boot unless celluloid_running
end
celluloid_logger_class() click to toggle source

returns the logger class from celluloid depending on version @return [Class] returns the logger class from celluloid depending on version

@api public :nocov:

# File lib/celluloid_pubsub/base_actor.rb, line 44
def celluloid_logger_class
  if version_less_than_seventeen?
    Celluloid::Logger
  else
    Celluloid::Internals::Logger
  end
end
celluloid_version() click to toggle source

returns the celluloid version loaded @return [String] returns the celluloid version loaded

@api public

# File lib/celluloid_pubsub/base_actor.rb, line 57
def celluloid_version
  find_loaded_gem_property('celluloid', 'version')
end
config() click to toggle source

returns the configuration classes and their aliases for celluloid @return [Hash] returns the configuration classes and their aliases for celluloid

@api public

# File lib/celluloid_pubsub/base_actor.rb, line 33
def config
  {
    'logger_class' => celluloid_logger_class
  }
end
included(base) click to toggle source

includes all the required modules in the class that includes this module @param [Class] base the class that will be used to include the required modules into it @return [void]

@api public

# File lib/celluloid_pubsub/base_actor.rb, line 18
def included(base)
  [
    Celluloid,
    Celluloid::IO,
    CelluloidPubsub::Helper,
    config['logger_class']
  ].each do |module_name|
    base.send(:include, module_name)
  end
end
setup_actor_supervision(class_name, options) click to toggle source

sets up the actor supervision based on celluloid version @param [Class] class_name The class that will be used to supervise the actor @param [Hash] options Additional options needed for supervision @return [void]

@api public :nocov:

# File lib/celluloid_pubsub/base_actor.rb, line 97
def setup_actor_supervision(class_name, options)
  actor_name, args = options.slice(:actor_name, :args).values
  if version_less_than_seventeen?
    class_name.supervise_as(actor_name, args)
  else
    class_name.supervise(as: actor_name, args: [args].compact)
  end
end
version_less_than_eigthteen?() click to toggle source

returns true if celluloid version less than 0.18, otherwise false @return [Boolean] returns true if celluloid version less than 0.17, otherwise false

@api public

# File lib/celluloid_pubsub/base_actor.rb, line 73
def version_less_than_eigthteen?
  verify_gem_version(celluloid_version, '0.18', operator: '<')
end
version_less_than_seventeen?() click to toggle source

returns true if celluloid version less than 0.17, otherwise false @return [Boolean] returns true if celluloid version less than 0.17, otherwise false

@api public

# File lib/celluloid_pubsub/base_actor.rb, line 65
def version_less_than_seventeen?
  verify_gem_version(celluloid_version, '0.17', operator: '<')
end