Sha256: 7ded03e5d336837f74bcced6cc17939e11ec01c2aedbeff1686780490d4cb6a0

Contents?: true

Size: 970 Bytes

Versions: 12

Compression:

Stored size: 970 Bytes

Contents

rad.mailer

class LetterBuilder < Rad::Conveyors::Processor
  def call                
    # prepare
    controller = workspace.controller.must_be.present
    raise "The controller #{controller} must be a Rad::Mailer::MailerController!" unless controller.is_a? Rad::Mailer::MailerController
    action = workspace.action = workspace.method_name

    # call
    content = catch :halt do
      controller.run_callbacks :action, method: action do          
        # call controller
        controller.send action, *workspace.arguments
        # render view
        controller.render action: action          
      end
    end
    
    controller.body = content unless content.blank?
    
    # letter
    workspace.letter = ::Rad::Mailer::Letter.new(
      from: controller.from,
      to: controller.to,
      subject: controller.subject,
      body: controller.body
    )
    workspace.letter.validate!
    
    next_processor.call if next_processor
  end          

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rad_core-0.0.25 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.24 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.23 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.22 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.21 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.20 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.19 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.18 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.17 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.16 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.15 lib/rad/mailer/processors/letter_builder.rb
rad_core-0.0.14 lib/rad/mailer/processors/letter_builder.rb