Class: Yuuki::Runner
- Inherits:
-
Object
- Object
- Yuuki::Runner
- Defined in:
- lib/yuuki/runner.rb,
sig/yuuki/runner.rbs
Instance Attribute Summary collapse
-
#yuuki ⇒ Caller?
readonly
Returns the value of attribute yuuki.
Class Method Summary collapse
-
.accumulated_decorators ⇒ Array[decorator]
Decorator-style DSL (
on/priority/thread/periodic/first_run) pushes entries here; the next instance-method definition consumes them (see method_added). - .first_run(enabled: true) ⇒ void
-
.inherited(subclass) ⇒ void
yuuki_methods is a per-class ivar, so copy it on inheritance to make runner methods defined in a superclass visible from the subclass.
-
.method_added(method_name) ⇒ void
Registers the method as a runner method when decorators are pending or the name is
on_<tag>(which implies the tag). - .on(tag) ⇒ void
- .periodic(interval) ⇒ void
- .priority(priority = 0) ⇒ void
- .singleton_method_added(_method_name) ⇒ void
- .thread(enabled: true) ⇒ void
- .yuuki_methods ⇒ Hash[Symbol, meta]
Instance Attribute Details
#yuuki ⇒ Caller? (readonly)
Returns the value of attribute yuuki.
5 6 7 |
# File 'lib/yuuki/runner.rb', line 5 def yuuki @yuuki end |
Class Method Details
.accumulated_decorators ⇒ Array[decorator]
Decorator-style DSL (on / priority / thread / periodic / first_run)
pushes entries here; the next instance-method definition consumes them
(see method_added). Both this and yuuki_methods live in per-class ivars.
10 11 12 |
# File 'lib/yuuki/runner.rb', line 10 def self.accumulated_decorators @accumulated_decorators ||= [] end |
.first_run(enabled: true) ⇒ void
This method returns an undefined value.
43 44 45 |
# File 'lib/yuuki/runner.rb', line 43 def self.first_run(enabled: true) accumulated_decorators << [:first_run, enabled] end |
.inherited(subclass) ⇒ void
This method returns an undefined value.
yuuki_methods is a per-class ivar, so copy it on inheritance to make runner methods defined in a superclass visible from the subclass. NOTE: methods added to the superclass after the subclass is defined are not reflected.
22 23 24 25 |
# File 'lib/yuuki/runner.rb', line 22 def self.inherited(subclass) subclass.instance_variable_set(:@yuuki_methods, yuuki_methods.dup) super end |
.method_added(method_name) ⇒ void
This method returns an undefined value.
Registers the method as a runner method when decorators are pending or the
name is on_<tag> (which implies the tag
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/yuuki/runner.rb', line 51 def self.method_added(method_name) return if accumulated_decorators.empty? && !method_name.start_with?('on_') = {} [:tags] = [method_name[3..].to_sym] if method_name.start_with?('on_') accumulated_decorators.each do |tag, elem| if tag == :tag [:tags] ||= [] [:tags] << elem else [tag] = elem end end accumulated_decorators.clear yuuki_methods[method_name] = super end |
.on(tag) ⇒ void
This method returns an undefined value.
27 28 29 |
# File 'lib/yuuki/runner.rb', line 27 def self.on(tag) accumulated_decorators << [:tag, tag] end |
.periodic(interval) ⇒ void
This method returns an undefined value.
39 40 41 |
# File 'lib/yuuki/runner.rb', line 39 def self.periodic(interval) accumulated_decorators << [:periodic, interval] end |
.priority(priority = 0) ⇒ void
This method returns an undefined value.
31 32 33 |
# File 'lib/yuuki/runner.rb', line 31 def self.priority(priority = 0) accumulated_decorators << [:priority, priority] end |
.singleton_method_added(_method_name) ⇒ void
This method returns an undefined value.
72 73 74 75 |
# File 'lib/yuuki/runner.rb', line 72 def self.singleton_method_added(_method_name) accumulated_decorators.clear super end |
.thread(enabled: true) ⇒ void
This method returns an undefined value.
35 36 37 |
# File 'lib/yuuki/runner.rb', line 35 def self.thread(enabled: true) accumulated_decorators << [:thread, enabled] end |
.yuuki_methods ⇒ Hash[Symbol, meta]
14 15 16 |
# File 'lib/yuuki/runner.rb', line 14 def self.yuuki_methods @yuuki_methods ||= {} end |