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, and :halt as mixins. You MUST NOT provide your own implementations of methods with these names in your model. All but :run are delegated to the EventScheduler class.
Defined Under Namespace
Classes: EventNotice, EventScheduler
Constant Summary collapse
- DELEGATED_METHODS =
The set of module methods to be passed to the EventScheduler if not found in the model class.
[:model_time, :schedule, :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.
23 24 25 26 27 28 29 |
# File 'lib/simplekit.rb', line 23 def method_missing(name, *args) if DELEGATED_METHODS.include?(name) @my_sim.send(name, *args) else super end end |
Instance Method Details
#run ⇒ Object
Run your model by creating a new EventScheduler and invoking its run method.
16 17 18 19 |
# File 'lib/simplekit.rb', line 16 def run @my_sim = EventScheduler.new(self) @my_sim.run end |