Sha256: cdf3d721d2ea79df70da5e66e08c83e0cdd390b4da4ebb610efe54ba18e287f7

Contents?: true

Size: 661 Bytes

Versions: 25

Compression:

Stored size: 661 Bytes

Contents

# HasOneEmailReview
# Allows any model to easily review an email template and make changes to the body

module HasOneEmailReview
  extend ActiveSupport::Concern

  module Base
    def has_one_email_review
      include ::HasOneEmailReview
    end
  end

  included do
    attr_accessor :email_review

    validate(if: -> { email_review.present? }) do
      self.errors.add(:base, 'reviewed email is invalid') unless email_review.valid?
    end
  end

  def build_email_review(atts = {})
    self.email_review ||= Effective::EmailReview.build(atts)
  end

  def email_review_attributes=(atts)
    self.email_review = Effective::EmailReview.new(atts)
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
effective_email_templates-1.0.11 app/models/concerns/has_one_email_review.rb
effective_email_templates-1.0.10 app/models/concerns/has_one_email_review.rb
effective_email_templates-1.0.9 app/models/concerns/has_one_email_review.rb
effective_email_templates-1.0.8 app/models/concerns/has_one_email_review.rb
effective_email_templates-1.0.7 app/models/concerns/has_one_email_review.rb