Class: Orthoses::Mixin
- Inherits:
-
Object
- Object
- Orthoses::Mixin
- Defined in:
- lib/orthoses/mixin.rb
Defined Under Namespace
Modules: Hook
Constant Summary collapse
- CALL_GRAPH =
{}
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(loader, if: nil) ⇒ Mixin
constructor
A new instance of Mixin.
Constructor Details
#initialize(loader, if: nil) ⇒ Mixin
Returns a new instance of Mixin.
28 29 30 31 32 |
# File 'lib/orthoses/mixin.rb', line 28 def initialize(loader, if: nil) CALL_GRAPH.clear @loader = loader @if = binding.local_variable_get(:if) end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/orthoses/mixin.rb', line 34 def call ::Module.prepend(Hook) store = @loader.call CALL_GRAPH.dup.each do |base_mod, mixins| base_mod_name = Utils.module_name(base_mod) or next content = store[base_mod_name] mixins.each do |(how, mod)| mod_name = Utils.module_name(mod) or next next if mod_name.start_with?("Orthoses") next unless @if.nil? || @if.call(base_mod, how, mod) store[mod_name].header = "module #{mod_name}" content << "#{how} #{mod_name}#{type_params_sig(mod)}" end end store end |