Skip to content

Instantly share code, notes, and snippets.

@beck03076
Created March 30, 2015 04:48
Show Gist options
  • Save beck03076/d4600d6df04ee795cfb7 to your computer and use it in GitHub Desktop.
Save beck03076/d4600d6df04ee795cfb7 to your computer and use it in GitHub Desktop.
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