Module: Sevgi::Graphics::Module
- Defined in:
- lib/sevgi/graphics/mixtures/call.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(mod, receiver) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 32 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) ⇒ Object
40 41 42 43 44 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 40 def self.callables(mod) raise 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) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 18 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) ⇒ Object
6 7 8 9 10 |
# File 'lib/sevgi/graphics/mixtures/call.rb', line 6 def method_added(method) super _callables << method if public_method_defined?(method) end |