Class: Legion::Extensions::Actors::Once
- Inherits:
-
Object
- Object
- Legion::Extensions::Actors::Once
- Includes:
- Base
- Defined in:
- lib/legion/extensions/actors/once.rb
Instance Method Summary collapse
- #cancel ⇒ Object
- #delay ⇒ Object
-
#initialize ⇒ Once
constructor
A new instance of Once.
Methods included from Base
#args, #check_subtask?, #enabled?, #function, #generate_task?, #manual, #runner, #use_runner?
Methods included from Helpers::Lex
#default_settings, #function_desc, #function_example, #function_options, #function_set, included, #runner_desc
Methods included from Helpers::Logger
Methods included from Helpers::Core
Methods included from Helpers::Base
#actor_class, #actor_const, #actor_name, #calling_class, #calling_class_array, #from_json, #full_path, #lex_class, #lex_const, #lex_name, #normalize, #runner_class, #runner_const, #runner_name, #to_dotted_hash
Constructor Details
#initialize ⇒ Once
Returns a new instance of Once.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/actors/once.rb', line 9 def initialize return unless enabled? if respond_to? :functions functions.each do function @task = Concurrent::ScheduledTask.execute(delay) do use_runner? ? runner : manual end end else @task = Concurrent::ScheduledTask.execute(delay) do use_runner? ? runner : manual end end rescue StandardError => e Legion::Logging.error e end |
Instance Method Details
#cancel ⇒ Object
32 33 34 35 36 |
# File 'lib/legion/extensions/actors/once.rb', line 32 def cancel return unless enabled? @task.cancel unless @task.cancelled? end |
#delay ⇒ Object
28 29 30 |
# File 'lib/legion/extensions/actors/once.rb', line 28 def delay 1.0 end |