Sha256: c2560343142f5ae256f754817c9386c893d6b1fd91f72accb26513cbcddde9fd

Contents?: true

Size: 724 Bytes

Versions: 1

Compression:

Stored size: 724 Bytes

Contents

class DeployNotification
  
  def initialize(deploy)
    @deploy = deploy
    @deployer = deploy.deployer
    @maintainers = deploy.project.maintainers
  end
  
  attr_reader :deploy, :deployer, :maintainers
  
  def deliver!
    messages = maintainers.map do |maintainer|
      ProjectNotification.maintainer_of_deploy(maintainer, deploy).deliver!
    end
    
    if we_know_who_triggered_the_deploy and it_wasnt_a_maintainer
      messages << ProjectNotification.maintainer_of_deploy(deployer, deploy).deliver!
    end
    
    messages
  end
  
private
  
  def we_know_who_triggered_the_deploy
    !deployer.blank?
  end
  
  def it_wasnt_a_maintainer
    !maintainers.with_email_address(deployer).exists?
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 app/mailers/deploy_notification.rb