Class: SendgridNotification::TemplateParametersValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/models/sendgrid_notification/template_parameters_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ TemplateParametersValidator

Returns a new instance of TemplateParametersValidator.



3
4
5
# File 'app/models/sendgrid_notification/template_parameters_validator.rb', line 3

def initialize(options)
  @parameter_keys ||= Array(options[:parameters]) || []
end

Instance Method Details

#validate(record) ⇒ Object



7
8
9
10
# File 'app/models/sendgrid_notification/template_parameters_validator.rb', line 7

def validate(record)
  params = @parameter_keys.map{|k| [k, k] }.to_h
  record.apply(params)
end