Created
March 30, 2015 04:48
-
-
Save beck03076/d4600d6df04ee795cfb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def evaluate_email_template email_template | |
expected_to_be_column = [] | |
model_column_names = [] | |
subject = email_template.subject.scan(/__.*?__/).map{|i| i.gsub(/__/,"").strip.downcase.tr(" ","_") } | |
body = email_template.body.scan(/__.*?__/).map{|i| i.gsub(/__/,"").strip.downcase.tr(" ","_") } | |
signature = email_template.signature.scan(/__.*?__/).map{|i| i.gsub(/__/,"").strip.downcase.tr(" ","_") } | |
expected_to_be_column << subject if subject.present? | |
expected_to_be_column << body if body.present? | |
expected_to_be_column << signature if signature.present? | |
expected_to_be_column = expected_to_be_column.flatten.uniq | |
valid?(expected_to_be_column) | |
end | |
def valid?(attrs) | |
instance = core.camelize.constantize.new | |
arr = [] | |
attrs.each do |attr| | |
arr << instance.respond_to?(attr.to_sym) | |
end | |
arr.all? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment