Class: Importable::ImportedItemParamsValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/importable/imported_item_params_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#importerObject (readonly)

Returns the value of attribute importer.



3
4
5
# File 'lib/importable/imported_item_params_validator.rb', line 3

def importer
  @importer
end

Instance Method Details

#validate(importer) ⇒ Object



5
6
7
8
9
10
# File 'lib/importable/imported_item_params_validator.rb', line 5

def validate(importer)
  @importer = importer
  required_params.each do |required|
    importer.errors[:base] << required[:message] if import_params[required[:name]].blank?
  end
end