Module: Sevgi::Graphics::Module Private
- Defined in:
- lib/sevgi/graphics/mixtures/call.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Callable drawing module support.
Class Method Summary collapse
-
.call(mod, receiver, *args, **kwargs) ⇒ Object?
private
Runs module hooks and callables against a receiver.
-
.callables(mod) ⇒ Array<UnboundMethod>
private
Returns the methods that should be executed for a callable module.
-
.extended(base) ⇒ void
private
Initializes callable module state.
Instance Method Summary collapse
-
#method_added(method) ⇒ Array<Symbol>?
private
Tracks newly defined public methods as callable drawing steps.
Class Method Details
.call(mod, receiver, *args, **kwargs) ⇒ Object?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 57 58 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 52 def self.call(mod, receiver, ...) mod._befores.each { receiver.Within(receiver, &it) } if mod.respond_to?(:_befores) && mod._befores # return last callable return value callables(mod).map { it.bind(receiver).call(...) }.last.tap do mod._afters.each { receiver.Within(receiver, &it) } if mod.respond_to?(:_afters) && mod._afters end end |
.callables(mod) ⇒ Array<UnboundMethod>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the methods that should be executed for a callable module.
64 65 66 67 68 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 64 def self.callables(mod) ArgumentError.("Must be a module: #{mod}") unless mod.instance_of?(::Module) (mod.respond_to?(:_callables) ? mod._callables : mod.instance_methods).map { mod.instance_method(it) } end |
.extended(base) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Initializes callable module state.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 31 def self.extended(base) base.instance_exec do @_callables = [] @_befores = [] @_afters = [] class << self attr_reader :_callables, :_befores, :_afters end extend(DSL) end end |
Instance Method Details
#method_added(method) ⇒ Array<Symbol>?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Tracks newly defined public methods as callable drawing steps.
11 12 13 14 15 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 11 def method_added(method) super _callables << method if public_method_defined?(method) end |