Sha256: a1def58db5d7ebec96d7f0a392d96f90c77fdeb34577836bce6608470e88ea10

Contents?: true

Size: 1011 Bytes

Versions: 24

Compression:

Stored size: 1011 Bytes

Contents

module Rad::Mailer::MailerController
  inherit Rad::Controller::Abstract

  attr_accessor :from, :to, :subject, :body

  module ClassMethods
    protected      
      inject conveyors: :conveyors
  
      def method_missing m, *args, &block
        mail_controller = self.new
        if mail_controller.respond_to? m
          build_letter mail_controller, m, *args
        else
          super
        end
      end        
    
      def build_letter mail_controller, m, *args
        conveyors.mail.must_be.present
        
        # copying parameter from current workspace if any
        # mail_workspace = rad.workspace? ? rad.workspace.clone : {}            
        # mail_workspace.merge!(
        #   controller: mail_controller,
        #   method_name: m,
        #   arguments: args
        # )

        workspace = conveyors.mail.call(
          controller: mail_controller,
          method_name: m,
          arguments: args
        )
        workspace.letter.must_be.present
      end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rad_core-0.0.17 lib/rad/mailer/_mailer_controller.rb
rad_core-0.0.16 lib/rad/mailer/_mailer_controller.rb
rad_core-0.0.15 lib/rad/mailer/_mailer_controller.rb
rad_core-0.0.14 lib/rad/mailer/_mailer_controller.rb