Module: CelluloidPubsub::BaseActor
- Extended by:
- Helper
- Defined in:
- lib/celluloid_pubsub/base_actor.rb
Overview
base actor used for compatibility between celluloid versions
Instance Attribute Summary collapse
-
#config ⇒ Hash
readonly
The configuration classes and their aliases.
Class Method Summary collapse
-
.boot_up ⇒ Boolean
tries to boot up Celluloid if it is not running.
-
.celluloid_logger_class ⇒ Class
returns the logger class from celluloid depending on version :nocov:.
-
.celluloid_version ⇒ String
returns the celluloid version loaded.
-
.config ⇒ Hash
returns the configuration classes and their aliases for celluloid.
-
.included(base) ⇒ void
includes all the required modules in the class that includes this module.
-
.setup_actor_supervision(class_name, options) ⇒ void
sets up the actor supervision based on celluloid version :nocov:.
-
.version_less_than_eigthteen? ⇒ Boolean
returns true if celluloid version less than 0.18, otherwise false.
-
.version_less_than_seventeen? ⇒ Boolean
returns true if celluloid version less than 0.17, otherwise false.
Methods included from Helper
action_subscribe?, actor_dead?, cell_actor, fetch_gem_version, filtered_error?, find_loaded_gem, find_loaded_gem_property, get_parsed_version, log_debug, own_self, parse_options, setup_celluloid_exception_handler, setup_celluloid_logger, setup_log_file, succesfull_subscription?, verify_gem_version
Instance Attribute Details
#config ⇒ Hash (readonly)
Returns The configuration classes and their aliases.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/celluloid_pubsub/base_actor.rb', line 9 module BaseActor class << self include Helper # 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 def included(base) [ Celluloid, Celluloid::IO, CelluloidPubsub::Helper, config['logger_class'] ].each do |module_name| base.send(:include, module_name) end end # returns the configuration classes and their aliases for celluloid # @return [Hash] returns the configuration classes and their aliases for celluloid # # @api public def config { 'logger_class' => celluloid_logger_class } end # returns the logger class from celluloid depending on version # @return [Class] returns the logger class from celluloid depending on version # # @api public # :nocov: def celluloid_logger_class if version_less_than_seventeen? Celluloid::Logger else Celluloid::Internals::Logger end end # :nocov: # returns the celluloid version loaded # @return [String] returns the celluloid version loaded # # @api public def celluloid_version find_loaded_gem_property('celluloid', 'version') end # 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 def version_less_than_seventeen? verify_gem_version(celluloid_version, '0.17', operator: '<') end # 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 def version_less_than_eigthteen? verify_gem_version(celluloid_version, '0.18', operator: '<') end # tries to boot up Celluloid if it is not running # @return [Boolean] returns true if Celluloid started false otherwise # # @api public def boot_up celluloid_running = begin Celluloid.running? rescue StandardError false end Celluloid.boot unless celluloid_running end # 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: def setup_actor_supervision(class_name, ) actor_name, args = .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 # :nocov: end end |
Class Method Details
.boot_up ⇒ Boolean
tries to boot up Celluloid if it is not running
81 82 83 84 85 86 87 88 |
# 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 ⇒ Class
returns the logger class from celluloid depending on version :nocov:
44 45 46 47 48 49 50 |
# 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 ⇒ String
returns the celluloid version loaded
57 58 59 |
# File 'lib/celluloid_pubsub/base_actor.rb', line 57 def celluloid_version find_loaded_gem_property('celluloid', 'version') end |
.config ⇒ Hash
returns the configuration classes and their aliases for celluloid
33 34 35 36 37 |
# File 'lib/celluloid_pubsub/base_actor.rb', line 33 def config { 'logger_class' => celluloid_logger_class } end |
.included(base) ⇒ void
This method returns an undefined value.
includes all the required modules in the class that includes this module
18 19 20 21 22 23 24 25 26 27 |
# 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) ⇒ void
This method returns an undefined value.
sets up the actor supervision based on celluloid version :nocov:
97 98 99 100 101 102 103 104 |
# File 'lib/celluloid_pubsub/base_actor.rb', line 97 def setup_actor_supervision(class_name, ) actor_name, args = .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? ⇒ Boolean
returns true if celluloid version less than 0.18, otherwise false
73 74 75 |
# 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? ⇒ Boolean
returns true if celluloid version less than 0.17, otherwise false
65 66 67 |
# File 'lib/celluloid_pubsub/base_actor.rb', line 65 def version_less_than_seventeen? verify_gem_version(celluloid_version, '0.17', operator: '<') end |