Class: Orthoses::Outputable::ConstantizableFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/orthoses/outputable/constantizable_filter.rb

Overview

Constantizable is an internal middleware It’s using on orthoses/outputable.rb

Instance Method Summary collapse

Constructor Details

#initialize(loader) ⇒ ConstantizableFilter

Returns a new instance of ConstantizableFilter.



8
9
10
# File 'lib/orthoses/outputable/constantizable_filter.rb', line 8

def initialize(loader)
  @loader = loader
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/orthoses/outputable/constantizable_filter.rb', line 12

def call
  @loader.call.tap do |store|
    failures = []
    store.each do |name, content|
      next if content.header
      next if content.interface?

      begin
        Object.const_get(name)
      rescue NameError, LoadError => err
        Orthoses.logger.error(err.inspect)
        failures << name
        next
      end
    end
    failures.each { |name| store.delete(name) }
  end
end