Module: SimpleKit
- Defined in:
- lib/simplekit.rb
Overview
The SimpleKit module provides basic event scheduling capabilities.
Including SimpleKit in your simulation model gives you methods :run, :model_time, :schedule, :cancel, :cancel_all, and :halt as mixins. DO NOT create your own implementations of methods with these names in your model. All but :run are delegated to the EventScheduler class.
Defined Under Namespace
Classes: EventScheduler
Constant Summary collapse
- DELEGATED_METHODS =
The set of module methods to be passed to the EventScheduler if not found in the model class.
%i[ model_time schedule cancel cancel_all halt ].freeze
Instance Method Summary collapse
-
#method_missing(name, *args) ⇒ Object
If a method doesn’t exist in the model class, try to delegate it to
EventScheduler. -
#run ⇒ Object
Run your model by creating a new
EventSchedulerand invoking itsrunmethod.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
If a method doesn’t exist in the model class, try to delegate it to EventScheduler.
26 27 28 |
# File 'lib/simplekit.rb', line 26 def method_missing(name, *args) DELEGATED_METHODS.include?(name) ? @my_sim.send(name, *args) : super end |
Instance Method Details
#run ⇒ Object
Run your model by creating a new EventScheduler and invoking its run method.
19 20 21 22 |
# File 'lib/simplekit.rb', line 19 def run @my_sim = EventScheduler.new(self) @my_sim.run end |