Class: Orthoses::ActiveDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/orthoses/active_decorator.rb,
lib/orthoses/active_decorator/version.rb

Constant Summary collapse

VERSION =
"0.2.0"

Instance Method Summary collapse

Constructor Details

#initialize(loader) ⇒ ActiveDecorator

Returns a new instance of ActiveDecorator.



7
8
9
# File 'lib/orthoses/active_decorator.rb', line 7

def initialize(loader)
  @loader = loader
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/orthoses/active_decorator.rb', line 11

def call
  @loader.call.tap do |store|
    decorator_modules.each do |mod|
      decorator_name = mod.name
      model_name = decorator_name.delete_suffix(decorator_suffix)
      begin
        model_name.constantize
      rescue NameError
        next
      end
      store[decorator_name].header = "module #{decorator_name} : #{model_name}"
    end
  end
end