Class: Orthoses::ActionMailer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/orthoses/action_mailer/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(loader) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/orthoses/action_mailer/base.rb', line 6

def initialize(loader)
  @loader = loader
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/orthoses/action_mailer/base.rb', line 10

def call
  @loader.call.tap do |store|
    ::ActionMailer::Base.descendants.each do |mailer_class|
      base_name = Utils.module_name(mailer_class) or next
      content = store[base_name]
      mailer_class.action_methods.each do |action_method|
        method_object = mailer_class.instance_method(action_method)
        parameters = method_parameters_to_rbs_method_type(method_object).to_s.gsub(' -> untyped', '')
        content << "def self.#{action_method}: #{parameters} -> ::ActionMailer::MessageDelivery"
      end
    end
  end
end